Skip to main content
fix repeated command
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
for line in $(cat file); do
  foo=$(echo $line | awk '{print $2}')
  bar=$(echo $line | awk '{print $3}')
  doo=$(echo $line | awk '{print $3$5}')
  echo $foo whatever $doo $bar
done
for line in $(cat file); do
  foo=$(echo $line | awk '{print $2}')
  bar=$(echo $line | awk '{print $3}')
  doo=$(echo $line | awk '{print $3}')
  echo $foo whatever $doo $bar
done
for line in $(cat file); do
  foo=$(echo $line | awk '{print $2}')
  bar=$(echo $line | awk '{print $3}')
  doo=$(echo $line | awk '{print $5}')
  echo $foo whatever $doo $bar
done
added 89 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
while IFS= read -r line; do
    someprog -f "$line"
done < inputfile-list.txt
<input<file-list.txt tr '\n' '\0' | xargs -r0 -n1 someprog -f 

Or with GNU xargs:

xargs -rd '\n' -n1 -a file-list.txt someprog -f
while IFS= read -r line; do
    someprog -f "$line"
done < input.txt
<input.txt tr '\n' '\0' | xargs -r0 -n1 someprog -f 
while IFS= read -r line; do
    someprog -f "$line"
done < file-list.txt
<file-list.txt tr '\n' '\0' | xargs -r0 -n1 someprog -f 

Or with GNU xargs:

xargs -rd '\n' -n1 -a file-list.txt someprog -f
added 10 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
<<input.txt tr '\n' '\0' | xargs -0r0 -n1 someprog -f 
< tr '\n' '\0' | xargs -0 -n1 someprog -f 
<input.txt tr '\n' '\0' | xargs -r0 -n1 someprog -f 
added 618 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
Loading
added 135 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
Unix is 50 now!
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link
Loading
typo
Source Link
terdon
  • 252.4k
  • 69
  • 480
  • 718
Loading
added 1 character in body
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Loading
added 42 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
typos
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
Remove duplicated lines.
Source Link
cuonglm
  • 158.2k
  • 41
  • 342
  • 420
Loading
added 1108 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
added 82 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
added 33 characters in body
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading
Source Link
Stéphane Chazelas
  • 585.4k
  • 96
  • 1.1k
  • 1.7k
Loading