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.
sh -c
comamnd:
- Definition:
sh
calls the programsh
as interpreter and the-c
flag means execute the following command as interpreted by this program.
- Top Engineering blogs:
- Airbnb
- Altassian
- Asana
- BitTorrent
- Canva
- Cloudera
- CLoudflare
- Cred
- Docker
- Dropbox
- Dunzo
- eBay
- Flipkart
- GitHub
- Groupon
- Hackerearth
- Intercom
- Lyft
- Meta
- MixPanel
- Netflix
- Nextdoor
- Paypal
- Practo
- Quora
- Salesforce
- Shopify
- Slack
- Soundcloud
- Spotify
- Stripe
- Swiggy
- Thoughtworks
- Thumbstack
- Tumblr
- Uber
- Yelp
- Zerodha
- Zomato
- Zoom