linux - /usr/bin/cut: Argument list too long in bash script -


i loaded csv file variable , trying cut out columns results in error /usr/bin/cut: argument list long. here did:

if [ $# -ne 1 ];      echo "you need add file name argument" fi   echo "input file name $1" input_file=$(<$1)  #cut required columns.  cut_input_file=$(cut -f 1,2,3,5,8,9,10 -d \| $input_file)  echo $(head $cut_input_file) 

what missing?

reason of error use of $input_file has full file data.

you need run cut on file not on file content use:

cut -f 1,2,3,5,8,9,10 -d '|' "$1" 

to run cut against file content use:

cut -f 1,2,3,5,8,9,10 -d '|' <<< "$input_file" 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -