Solved

Passing arguments to a script through a pipe

Posted on 2006-11-17
2
232 Views
Last Modified: 2010-04-21
Hi!,
    I want to grep through a file and pass the result of the grep command to a shell script(I use $1, $2, etc to recognize arguments). However, I don't know how to do something like this. I don't want to edit the script itself as I may want to grep through another file.

Thank you!
0
Comment
Question by:astracter
2 Comments
 
LVL 43

Accepted Solution

by:
ravenpl earned 250 total points
ID: 17965232
You can: grep "pattern" file | xargs ./script.sh
But how will You know how many args the script expects?
Also, xargs may call Your script many time if grep output is too long to fit in one script call (argument list is limited in it's length)
0
 

Author Comment

by:astracter
ID: 17965799
Thank you!,  Actually it's not just a grep...It's a loooooooooooooooong pipe(a lot of seds), The script only expects 1 argument and grep only returns one line. :)

Thank you!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Debian 3.16.7 3 148
pipe to sed or perl, please help 5 128
linux $PWD 2 629
Linux : can't create transaction lock on rpm.lock (Permission denied) 10 231
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question