繁体   English   中英

/ usr / bin / cut:bash脚本中的参数列表过长

[英]/usr/bin/cut: Argument list too long in bash script

我将一个csv文件加载到一个变量中,然后尝试剪切出一些列,从而导致此错误/ usr / bin / cut:参数列表过长 这是我所做的:

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)

我想念什么?

该错误的原因是您使用了具有完整文件数据的$input_file

您需要对文件而不是文件内容进行cut ,因此请使用:

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

要针对文件内容运行cut ,请使用:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM