/usr/bin/cut : Argument list too long in bash script
load a csv file into a variable, and then I try to remove some of the columns that are causing this error /usr/bin/cut: Argument list too long. Here’s what I did :
if [ $# -ne 1 ]; then echo "you need to add the file name as argument" fi echo "input file name $1" input_file=$(<$1) #cut the required columns. cut_input_file=$(cut -f 1,2,3,5,8,9,10 -d \| $input_file) echo $(head $cut_input_file)
What am I missing?
The cause of this error is that you used
$input_file with full file data.
You need to run
cut on the file and not the file contents, so use:
cut -f 1,2,3,5,8,9,10 -d '|' "$1"
cut: against the contents of the file
cut -f 1,2,3,5,8,9,10 -d '|' <<< "$input_file"