Unix Commands I Abuse Every Day
everythingsysadmin.com
Unix Commands I Abuse Every Day
1–10 of 108 posts
Re: Unix Commands I Abuse Every Day
#2A lot of people like writing bash for loops, I will try and avoid that as much as possible, xargs -n1 is the bash equivalent of a call to 'map' in a functional language.
For instance, let's say you want to create thumbnails of a bunch of jpegs:
find images -name "*.jpg" | xargs -n1 -IF echo F F | sed -e 's/.jpg$/_thumb.jpg/' | xargs -n2 echo convert -geometry 200x
Additionally, it's fully parallelizable as xargs supports something akin to pmap.
Re: Unix Commands I Abuse Every Day
#3Normally I'd typed something like "grep -i 'something' foo | less", and wanted to just up arrow the previous line and change the grep stuff to cat. I don't know why, it doesn't really save me anything. Maybe it's the hackerish "because I can, that's why" instinct at work.
Re: Unix Commands I Abuse Every Day
#4My #1 abuse is xargs -n1. A lot of people like writing bash for loops, I will try and avoid that as much as possible, xargs -n1 is the bash equivalent of a call to 'map' in a functional language. For instance, let's say you want to create thumbnails of a bunch of jpegs: find images -name "*.jpg" | xargs -n1 -IF echo F F | sed -e 's/.jpg$/_thumb.jpg/' | xargs -n2 echo convert -geometry 200x Additionally, it's fully pa…
Your trivial example:
find images -name "*.jpg" | parallel convert -geometry 200x {} {.}_thumb.jpg
Re: Unix Commands I Abuse Every Day
#5My #1 abuse is xargs -n1. A lot of people like writing bash for loops, I will try and avoid that as much as possible, xargs -n1 is the bash equivalent of a call to 'map' in a functional language. For instance, let's say you want to create thumbnails of a bunch of jpegs: find images -name "*.jpg" | xargs -n1 -IF echo F F | sed -e 's/.jpg$/_thumb.jpg/' | xargs -n2 echo convert -geometry 200x Additionally, it's fully pa…
If you like xargs, but want jobs to execute in parallel, you may enjoy GNU parallel. Your trivial example: find images -name "*.jpg" | parallel convert -geometry 200x {} {.}_thumb.jpg
Re: Unix Commands I Abuse Every Day
#6Therefore every time you use it to spool one file into a pipeline, that is technically an abuse!
Re: Unix Commands I Abuse Every Day
#7Re: Unix Commands I Abuse Every Day
#8Re: Unix Commands I Abuse Every Day
#9My #1 abuse is xargs -n1. A lot of people like writing bash for loops, I will try and avoid that as much as possible, xargs -n1 is the bash equivalent of a call to 'map' in a functional language. For instance, let's say you want to create thumbnails of a bunch of jpegs: find images -name "*.jpg" | xargs -n1 -IF echo F F | sed -e 's/.jpg$/_thumb.jpg/' | xargs -n2 echo convert -geometry 200x Additionally, it's fully pa…
Re: Unix Commands I Abuse Every Day
#10cat foo | less Normally I'd typed something like "grep -i 'something' foo | less", and wanted to just up arrow the previous line and change the grep stuff to cat. I don't know why, it doesn't really save me anything. Maybe it's the hackerish "because I can, that's why" instinct at work.
cat !$ | less
!$ is "the last argument to the previous command".