简体   繁体   中英

“While read line” command is not taking all the lines from the input file

I am using the below code.

while read line
do
  word_1=`echo $line | cut -d"[" -f1`
  word_2=`echo $line | cut -d"[" -f2`
  echo "$word_1|$word_2"
done < Input_file

my input file has 1000 lines, but the above code processing only few lines. And not getting any errors while running the command.

This does not answer your question, we need more info. However, you're doing too much work. A simpler version:

while IFS='[' read -r word1 word2 rest_of_line
do
  echo "$word_1|$word_2"
done < Input_file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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