Solved

Passing arguments to a script through a pipe

Posted on 2006-11-17
2
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

696 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