Skip to content

Latest commit

 

History

History
73 lines (63 loc) · 2.84 KB

09282022.md

File metadata and controls

73 lines (63 loc) · 2.84 KB
  1. xargs -I command option:
  • Definition: -I <replace-str> ~ Replace occurrences of <replace-str> in the initial-arguments with names read from standard input.

  • Exp:

### From: https://stackoverflow.com/questions/7935733/heads-and-tails-trying-to-get-first-line-and-last-ten-lines-of-each-file

# Get the first and last ten lines from a file:
ls output/*Response | \
  sort -t_ --key=2 -g | \
  xargs -I {} sh -c 'head -1 {}; tail {}' | \
  less

ls output/*Response | \
  sort -t_ --key=2 -g | \
  ((head -n 1) && (tail -n 10)) | \
  less

### End from.
  1. sh -c comamnd:
  • Definition: sh calls the program sh as interpreter and the -c flag means execute the following command as interpreted by this program.
  1. Top Engineering blogs: