簡體   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