Solved

Passing arguments to a script through a pipe

Posted on 2006-11-17
2
233 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

789 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