Solved

Passing arguments to a script through a pipe

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now