[bash] how to use _piped_ data in a shellscript?

If you want to talk about your personal paperweight, you've found the right place!

Moderator: Moderators

[bash] how to use _piped_ data in a shellscript?

Postby joe3 » Tue Apr 01, 2008 21:59

I have a utility script that among other things opens a personal "snippage" text file for interactive editing with vim. Here is a section of the shellscript:

- - - - - - - - -< s n i p >- - - - - - - - - -

if [ $@ == "" ]
then
echo "No snipData in arg list"
else
echo "
+++++++======== begin (arg list) snipData on "`date`"
$@
+++++++======== end snipData
">>$snip/toit.txt
fi

- - - - - - - - -< s n i p >- - - - - - - - - -

With this I can get the contents of a text file appended to toit.txt with a command like:

$ toit `cat test.txt`

But what I want to be able to do is to accomplish the same thing by.

$ cat test.txt|toit

But I have no idea how to redirect the piped input into a variable so that my script can manipulate it...

Would someone be so kind as to give me a clue?
--
joe3
joe3
Advanced Hen
 
Posts: 200
Joined: Sun May 06, 2007 21:28

Re: [bash] how to use _piped_ data in a shellscript?

Postby xlnagla » Sat Apr 05, 2008 21:07

xlnagla
Sagely Hen
 
Posts: 1078
Joined: Mon May 28, 2007 2:44


Return to Off Topic

Who is online

Users browsing this forum: No registered users and 1 guest

cron