?
Solved

Passing arguments to a script through a pipe

Posted on 2006-11-17
2
Medium Priority
?
240 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 1000 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 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