Using bash inline

<<<"k=1024; m=k*k; g=k*m; g" bc
There are two ways to use "here documents" with bash to fill stdin: The following example shows use with the "bc" command. a) Using a delimiter at the end of data: less-than less-than eeooff bc > k=1024 > m=k*k > g=k*m > g > eeooff 1073741824 b) using the "inline" verion with three less-than symbols: less-than less-than less-than "k=1024; m=k*k; g=k*m; g" bc 1073741824 One nice advantage of using the triple less-than version is that the command can easily be recalled from command line history and re-executed. PS: in this "description", I had to use the name "less-than" to represent the less-than symbol because the commandlinefu input text box seems to eat up the real less-than symbols. Odd.
Sample Output
$ # example 1: with the "bc" (basic calculator) command
$ <<<"k=1024; m=k*k; g=k*m; g" bc
1073741824

$ # example 2: with the "at" command
$ <<< "/home/mirror/cron_rsync_mandriva_updates" at now + 1 min
warning: commands will be executed using (in order) a) $SHELL b) login shell c) /bin/sh
job 66 at Sat Jun 20 11:33:00 2009


$ # example 3: calculating how long it takes for a signal across the Atlantic in fibre optic cable
$ # reference: https://en.wikipedia.org/wiki/Speed_of_light
$ # example 3, part 1: how fast does light travel in glass?
$ bc <<< "scale=4;  speedoflight=186282; speedoflight/1.5"    # light in glass travels at c / 1.5
124188.0000
$ # example 3, part 2: how many seconds for light to cross Atlantic in glass?
$ bc <<< "scale=4; ocean=3716; speedoflight=124188; ocean/speedoflight"
.0299

9
By: mpb
2009-06-17 10:35:10

1 Alternatives + Submit Alt

What Others Think

Why not simply use echo? echo "k=1024; m=k*k; g=k*m; g" | bc I think it's easier to understand, and it's more portable (works with any bourne shell, not just bash and zsh).
inof · 769 weeks and 5 days ago
@inof The point is to show the use of the " Sure, echo is an alternative but it means you have to use a pipe. I am here on commandlinefu to learn *new* things.
mpb · 769 weeks and 4 days ago
eh? that's odd: what happened to the three less-than symbols in my previous comment? Some odd character handing in the text input box for commandlinefu? It would also be nice to be able to edit comments (eg for spelling correctione etc).
mpb · 769 weeks and 4 days ago
What is the "three less-thans" operation actually called? I can't figure it out, and it's not in the TLDP guide!
chriszuma · 634 weeks ago
The "three-less-thans" operator is called a Here String in the bash man page. See also chapter 19.1 of the Advanced Bash-Scripting Guide in the TLDP.
bobnewstadt · 626 weeks and 3 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale pug puppies indiana Amazing! This blog looks just like my old one! It's on a completely different subject but it has pretty much the same layout and design. Wonderful choice of colors!
rahimhh21 · 80 weeks ago
Since 2008, Perfect House Pug Puppies has been the leading Pug puppy breeder in the US, providing premium Pug puppies for sale. Each puppy exhibits the professionalism and knowledge that have set Perfect House Pug puppies apart from other pug puppy breeders. The professionals at Perfect House Pug Puppies are dedicated about finding their puppies loving, beloved homes where they can enjoy long, healthy lives. A companion that has been produced for quality, health, and temperament that satisfies the breed standard is guaranteed by Perfect House Pug puppies, the pug breeder that has set the benchmark for exceptional customer satisfaction. If you are looking to buy a baby pug, Black and white pugs, Mini pug puppies for sale, Black and tan pug for sale, Teacup pug puppies for sale, Female pug puppies, pug puppies for sale, pug puppies for sale near me, pug puppies for sale under $500 near me. Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies baby pug puppies for sale pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
Perfecthomepugs · 71 weeks and 6 days ago
EVERYONE in the family Priority number one. We're small-scale, in-home breeders. We're not a facility or a kennel; we're a group of Pug enthusiasts who are utterly smitten with our adorable kids. Perfect House of Pugs is just breathtaking! Our Pugs have the best temperaments and personalities. They are created specifically for families looking for a high-quality Pug puppy. With over 18+ years, we have fought for only the finest standards, with our Pugs' health as our primary emphasis, which is why we put EVERYTHING into it, never cutting corners, always changing, and always improving. Our children are our greatest source of pride and delight. Our mission is to build connections (rather than merely sell puppies) and to bring pleasure and joy into your household. We are raising a Pug family and are certain that these puppies will become an integral part of your life. PLEASE VISIT OUR WEBSITE LINK BELLOW FOR MORE INFORMATION ABOUT PUG PUPPIES. PUG PUPPY ADOPTION Pug puppies for sale PUG PUPPIES FOR SALE NEAR ME PUG PUPPIES NEAR ME PUG PUPPIES FOR SALE UNDER 500 NEAR ME CUTE PUG PUPPIES BLACK PUG PUPPIES BLACK PUG PUPPIES FOR SALE PUG PUPPIES FOR ADOPTION BLACK PUG PUPPIES FOR SALE NEAR ME CHIHUAHUA PUG MIX PUPPIES TEACUP PUG PUPPIES HOW MUCH IS A PUG PUPPY BABY PUG PUPPIES PICTURES OF PUG PUPPIES PUG PUPPIES FOR SALE IN OHIO PUG PUPPIES FOR SALE IN PA PUG PUPPIES PRICE PUG MIX PUPPIES TEACUP PUG PUPPIES FOR SALE BABY PUG PUPPIES FOR SALE BEST FOOD FOR PUG PUPPY NEWBORN PUG PUPPIES PUG PUPPIES CRAIGSLIST PUG PUPPIES FOR SALE CRAIGSLIST WHITE PUG PUPPIES PUG PUPPIES FOR SALE IN MICHIGAN PUG PUPPIES FOR SALE UNDER 500 ADORABLE PUG PUPPIES BRINDLE PUG PUPPY HOW MUCH DOES A PUG PUPPY COST PITBULL PUG MIX PUPPIES PUGS FOR SALE NEAR ME PUG PUPPIES FOR SALE 200 PUG PUPPIES FOR SALE IN NJ PUG PUPPIES FOR SALE IN WISCONSIN PUG PUPPIES MICHIGAN PUG PUPPY COST MERLE PUG PUPPY FOR ADOPTION BEST PUG PUPPY FOOD ROYAL CANIN PUG PUPPY FOOD FAWN PUG PUPPY PUG PUPPIES FOR SALE FLORIDA PUG PUPPIES FOR SALE IN INDIANA PUG PUPPIES FOR SALE IN KY PUG PUPPIES FOR SALE IN NC PUG PUPPIES FOR SALE IN TEXAS PUG PUPPIES FOR SALE MN PUG DOG PUPPY AKC REGISTERED PUG PUPPIES FOR SALE PUG ALL BLACK CHEAP PUG PUPPIES FOR SALE NEAR ME PUGS PUPPIES FOR SALE CHEAP PUG PUPPIES FOR SALE IN CALIFORNIA MINIATURE PUG PUPPIES FOR SALE NEAR ME MINIATURE PUG PUPPIES FOR SALE CHEAP PUG PUPPIES FOR SALE IN NJ KNOWN FACTS ABOUT PUG PUPPIES ADOPT PUG PUPPIS RESCUE A PUG PUPPY PERFECT HOUSE OF PUGS PUG PUPPIES INSTAGRAM PINTEREST QUORA Google Page USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA
pugpuppies95 · 33 weeks and 6 days ago
Acquista Ossicodone ItaliaAcquista Ossicodone Italia  Acquista cocaina crack in linea cocaina a squame di pesce italia Acquista cocaina boliviana in linea Acquista Saxenda in Linea Acquista fentermina in linea italia Acquista Ozempic In Linea Acquista Stilnox in linea italia Acquista Ambien in linea italia Acquista Quaaludes in linea Acquista Metaqualone In Linea Acquista subutex in linea italia Acquista Adderall In linea italia Acquista Ossicodone 10 mg Sandoz italia Acquista Laudano droga online Acquista ossicodone pillole Acquista desoxyn in linea italia Acquista buprenorfina in linea italia Acquista ritalin in linea italia Acquista dilaudid in linea italia Acquista ritalin in linea italia Acquista Ossicodone 30 mg Sandoz italia Acquista fentanil in linea italia Acquista Ossicodone Italia Acquista Ossicodone Italia Acquista la morfina iniettabile Italia Acquista Ossicodone 80 mg Sandoz italia Acquista Xanax in linea italia Acquista strisce di Suboxone italia Acquista vyvanse in linea italia Acquista oxycontin in linea italia Acquista Percocet in linea italia Acquista ossicodone pillole in linea italia Acquista morfina in linea italia Acquista ossicodone in linea italia Buy wood online Buy wood pellets online  dried-pods for sale  opium-pods  for sale dried-papaver-pods  dried poppy pods in USA free dried podsdried poppy pods   körkort sverigekörkort sverige köp körkort köp falsk pass BESTÄLLA KÖRKORT ONLINE buy dried poppy pods online buy opium pods buy opium pods Buy dried poppies online dried poppy pods unwashed poppy pods for sale Dried poppy pods near me Poppy seed tea dried poppy pods for craft wholesale dried flowers USA Giant dried poppy heads dried poppy pods dried poppy pods   Führerschein kaufen ohne prüfungkaufen MPU GutachtenKaufen bootsführerschein onlineSchweizer Führerschein kaufen führerschein polen kaufen ohne prüfung FÜHRERSCHEIN ONLINE KAUFEN https://eu-fuhrerscheinlegal.com/product/kaufen-deutschland-fuhrerschein/ Buy wood online Buy wood pellets online
donperi1 · 27 weeks ago
Acquista Ossicodone ItaliaAcquista Ossicodone Italia  Acquista cocaina crack in linea cocaina a squame di pesce italia Acquista cocaina boliviana in linea Acquista Saxenda in Linea Acquista fentermina in linea italia Acquista Ozempic In Linea Acquista Stilnox in linea italia Acquista Ambien in linea italia Acquista Quaaludes in linea Acquista Metaqualone In Linea Acquista subutex in linea italia Acquista Adderall In linea italia Acquista Ossicodone 10 mg Sandoz italia Acquista Laudano droga online Acquista ossicodone pillole Acquista desoxyn in linea italia Acquista buprenorfina in linea italia Acquista ritalin in linea italia Acquista dilaudid in linea italia Acquista ritalin in linea italia Acquista Ossicodone 30 mg Sandoz italia Acquista fentanil in linea italia Acquista Ossicodone Italia Acquista Ossicodone Italia Acquista la morfina iniettabile Italia Acquista Ossicodone 80 mg Sandoz italia Acquista Xanax in linea italia Acquista strisce di Suboxone italia Acquista vyvanse in linea italia Acquista oxycontin in linea italia Acquista Percocet in linea italia Acquista ossicodone pillole in linea italia Acquista morfina in linea italia Acquista ossicodone in linea italia Buy wood online Buy wood pellets online  dried-pods for sale  opium-pods  for sale dried-papaver-pods  dried poppy pods in USA free dried podsdried poppy pods   körkort sverigekörkort sverige köp körkort köp falsk pass BESTÄLLA KÖRKORT ONLINE buy dried poppy pods online buy opium pods buy opium pods Buy dried poppies online dried poppy pods unwashed poppy pods for sale Dried poppy pods near me Poppy seed tea dried poppy pods for craft wholesale dried flowers USA Giant dried poppy heads dried poppy pods dried poppy pods   Führerschein kaufen ohne prüfungkaufen MPU GutachtenKaufen bootsführerschein onlineSchweizer Führerschein kaufen führerschein polen kaufen ohne prüfung FÜHRERSCHEIN ONLINE KAUFEN https://eu-fuhrerscheinlegal.com/product/kaufen-deutschland-fuhrerschein/ Buy wood online Buy wood pellets online
donperi1 · 27 weeks ago
TIMUR188 Bukan hanya sekedar memberikan statement sebagai situs tergacor 2023 saat ini, kami membuktikan dengan memberikan jaminan garansi gacor 100% atau biasa di sebut garansi kekalahan 100%. Yang di mana apabila member baru deposit dan mengalami kekalahan pertamanya maka member berhak mengklaim garansi kekalahan 100% sesuai dengan syarat dan ketentuan yang berlaku. Menarik kan ? Main slot kalah dan bisa klaim kembali saldo nya. Promo ini hanya berlaku untuk member yang baru melakukan deposit untuk pertama kali nya. Cara klaim nya juga sangat mudah sekali. Member hanya perlu melapor ke CS Livechat TIMUR188 yang bertugas 24 jam dimana fitur klaim garansi nya terdapat di bagian pojok kanan bawah di halaman situs kami. Gabung sekarang juga jangan sampai ketinggalan promo bonus menarik yang sudah ditawarkan, segera klik langsung tombol yang disediakan diatas untuk bergabung dengan Situs TIMUR188 yang sudah kami Bagikan
wandasuwari · 9 weeks and 1 day ago
Selamat datang di situs TIMUR188 Bagi kalian yang gemar bermain game online, kalian telah berada di tempat yang tepat. TIMUR188 adalah situs game online yang gacor dan terpercaya. Di sini, kalian dapat menikmati berbagai jenis permainan seru dan mendapatkan pengalaman bermain yang tak terlupakan. Untuk memulai bermain di TIMUR188, kalian hanya perlu mendaftar dan membuat akun secara gratis. Proses pendaftaran sangat mudah dan cepat, sehingga kalian tidak perlu repot-repot menunggu lama untuk bisa bermain. Setelah memiliki akun, kalian bisa melakukan deposit dengan mudah melalui berbagai metode pembayaran yang disediakan. TIMUR188 juga menyediakan layanan customer service yang siap membantu kalian 24 jam non-stop. Jika kalian mengalami kendala atau memiliki pertanyaan seputar situs ini, kalian bisa langsung menghubungi customer service melalui live chat atau kontak yang disediakan. TIMUR188 selalu siap memberikan solusi terbaik untuk kalian. Selain kelancaran akses, keamanan juga menjadi prioritas utama di situs ini. TIMUR188 menggunakan sistem keamanan yang canggih dan terpercaya untuk melindungi data pribadi dan transaksi kalian. Kalian dapat bermain dengan tenang tanpa khawatir data kalian akan disalahgunakan oleh pihak yang tidak bertanggung jawab. Jadi, tunggu apalagi? Bergabunglah sekarang juga di situs TIMUR188 dan nikmati pengalaman bermain game online yang gacor dan terpercaya. Dapatkan keseruan dan keuntungan yang tidak akan kalian temukan di situs lain. Jangan lewatkan kesempatan emas ini! Selamat bermain Salap Jp dari TIMUR188
KarinTaufik12 · 7 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: