I saw it on Twitter:
Retweeted by Ming Tang
todays fav linux oneliner:
command | (read -r; printf "%s\n" "$REPLY"; sort) > output
sort everything except first line.
REPLY is the default variable for the read command.
one more general use of the "body" function
http://stackoverflow.com/questions/9281449/unix-skip-header-bash-function
http://unix.stackexchange.com/questions/11856/sort-but-keep-header-line-in-the-at-the-top
# print the header (the first line of input)
# and then run the specified command on the body (the rest of the input)
# use it in a pipeline, e.g. ps | body grep somepattern
body() {
IFS= read -r header
printf '%s\n' "$header"
"$@"
}
IFS is the bash Shell Bourne variable: A list of characters that separate fields used by the shell to split text strings.$# Stores the number of command-line arguments that
were passed to the shell program.
$? Stores the exit value of the last command that was
executed.
$0 Stores the first word of the entered command (the
name of the shell program).
$* Stores all the arguments that were entered on the
command line ($1 $2 ...).
"$@" Stores all the arguments that were entered
on the command line, individually quoted ("$1" "$2" ...).
Or an awk solution awk 'NR == 1; NR > 1 {print $0 | "sort -n"}'
It is very handy to use.
Test:
tommy@tommy-ThinkPad-T420:~$ cat body_sort.txt
header
4
6
9
7
14
8
tommy@tommy-ThinkPad-T420:~$ cat body_sort.txt |( read -r; printf "%s\n" "$REPLY"; sort -n)
header
4
6
7
8
9
14
ReplyDeleteWow!!! It was really an Informational Article which provide me with much Insightful Information. I would like to first thank the author for such an Insightful Content. If someone here is looking for a Website Designing Company in India, then look no further than Jeewangarg.com as we are the best website design company in Delhi working in the arena for the last 8 years.
Best website designing company in India
website designing company in Delhi NCR
Thank You Author!!! You are sharing the very informative and great post. If anyone is looking to lehenga indian wedding dresses | lehenga online .
ReplyDeleteAn excellently written article if only all blogger offered the same level of content as you the internet would be a much better place. Please keep it up!. Great tips, please check this one 123movies
ReplyDeleteThanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you once agian
ReplyDeletewe offer services delhi birth certificate which inculde name add in birth certificate and birth certificate correction complete process is online and we offer
birth certificate and we offer this birth certificate online same service offers at yourdoorstep at birth certificate in ghaziabad our dream to provide birth certificate in india and other staes like birth certificate in bengaluru and birth certificate in gurgaon book service with us birth certificate in noida also, service at yoursdoorstep only birth certificate in india or
Online Front is a professional digital marketing company in Delhi. You can get the best digital marketing services by online front. We have an expert team of digital marketing who make the best strategy to promote your business through Google, Facebook, Instagram, and other social media platforms. We know it might be tough to achieve the target but not impossible. And our team proved! you can check our previous work with our previous client.
ReplyDeleteVisit For More Info:-
Website Development Company In Delhi
Digital Marketing Company In Delhi
Website Development Packages
Website Designing company in delhi
Social Media Management Packages
Email Marketing Services
Visit Our Partner’s Site:-
Gas Stove Repair & Services in Delhi
B2B Marketplace in Delhi
Satta King
This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ..
ReplyDeletecollage call girl service in jind
collage call girl service in jhajjar
collage call girl service in fatehabad
collage call girl service in charkhi dadri
collage call girl service in bhiwani
**Hello my dear !!! I'm Kunjan and I want to thank you for visiting my profile. My City Escort Services are TOP quality and I can guarantee your satisfaction. The reason is that I do City Escort job with pleasure and I enjoy every part of it. With my beautiful lips, big deep eyes, and brown soft skin you can turn your dreams into reality!!! My pictures are recent, I'm Real and I don't waste time to hang out with this Sexy City Escort. Take a break from your stressful lifestyles and enjoy a relaxing time with me. I promise you, all the moments spend with me will make you come back for more. Sometimes I can be crazy and evil as hell!! I'm 100% independent!! Give me a call anytime will be fun and nice for both of us! as a City Call Girl.
ReplyDeleteMahendragarh Call Girls !!
Karnal Call Girls !!
Kaithal Call Girls !!
Jind Call Girls !!
Jhajjar Call Girls !!
Fatehabad Call Girls !!
Faridabad Call Girls !!
Charkhi Dadri Call Girls !!
Bhiwani Call Girls !!
Nice blog, with very relevant information, get back to us for some inspiring content. We are also serving in the same domain delivering top-notch mobile app development solutions. For more details, visit iphone app development company or contact us: +91-9717270746 or email us: sales@appsquadz.com
ReplyDeleteHello gentlemen, the name is Sneha and I am a genuine 23-year-old independent call girl. I am willing to do everything with great affection and offer you for our delicious sex encounter.
ReplyDeleteRelationship
Call girls
Call girl
Female
Call girls for party
Hotel call girls
Model
Incall girls
Outcall girls
Escort service
Female call girls service
Erotic massage
Call girls number
Call girl number
Call girls WhatsApp
Call girl WhatsApp
Escort Service In Ludhiana |
ReplyDeleteEscorts Services in Ludhiana |
Escorts Service in Ludhiana |
Escort Services In Ludhiana |
Call Girl in Ludhiana |
Independent Call Girl In Ludhiana |
Sexy Call Girl In Ludhiana |
Hot Call Girl in Ludhiana |
Best Call Girl in Ludhiana |
This post is so interactive and informative.keep update more information...
ReplyDeleteAWS Training in Anna Nagar
AWS Training in Chennai
It's remarkable. The way you describe the information is awesome. This will really help me out. Thanks for sharing.
ReplyDeleteTableau Training in Chennai
Tableau Course in Chennai
Tableau Online Course
Every one deserves to be happy in their family or relationships, I was lucky enough to get my husband back , Doctor Robbinson helped me he is authentic , My Husband left me for 8 months and I was devastated and couldn't find any way out to get him back i tried all ways. At some point I was depressed, while i was reading through some post on the internet where people testified about how Dr Robbinson helped them Solve similar problems I contacted him and he never hesitated to help me as well, My husband is back home, my happiness is restored
ReplyDeleteText/call: +12267705795
Email: Drrobbinssonspiritualhome@gmail.com