Pipe output a command to another using xargs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pipe output a command to another using xargs
# 1  
Old 04-12-2013
Ubuntu Pipe output a command to another using xargs

xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it.


$ scr.sh
gives output like

193740
638102
375449
..
..

another command takes these number as inputs. it works great when done separately.
$ show data 193740
which gives report on this. I want a full report of all these number.

I tried like this:

$ scr.sh | xargs show data
but it doesn't work. Please provide your inputs on this.Smilie
# 2  
Old 04-12-2013
xargs will try to cram them all into one call unless you tell it otherwise.

Code:
scr.sh | xargs -n 1 show data

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the output of w command in pipe delimited format

Since output of w command have variable number of columns I want to get the output in pipe delimited format. I tried export OFS="|"; w but that does not work. Any ideas? (4 Replies)
Discussion started by: Soham
4 Replies

2. SuSE

Find command doesn't pipe the output as required.

Hi, I am using below code snippet to echo/display the files found (matching a pattern from searchstring.out file) and the corresponding owner. while read j do echo "Pattern to search is:- $j" find / -name "*$j*" |\ while read k do echo "File found is:- $k" owner=$(ls... (9 Replies)
Discussion started by: Vipin Batra
9 Replies

3. Shell Programming and Scripting

How to pipe command output to shell script?

Hi Team, Need a help on how to pipe a command out put to a shell script. My shell script looks like below. cat shell_script #!/usr/bin/ksh input =$@ echo " we are inside the shell script" echo " here are the input parameters" .......................... .................. ... (11 Replies)
Discussion started by: gvkumar25
11 Replies

4. UNIX for Dummies Questions & Answers

xargs vs. pipe

I have been using unix on and off for a number of years. I am not a sys admin. I use what I need. I have googled this, but I really can't figure out what is the difference between using xarg and just using a regular pipe? Why do I need to include xarg sometimes and how do I know when I need it? (2 Replies)
Discussion started by: guessingo
2 Replies

5. Programming

difference bewteen pipe, xargs, and exec

I have read several docs on these on the web and looked at examples. I can't figure out the difference. In some cases you use one or the other or you combine them. can someone help me understand this? (1 Reply)
Discussion started by: guessingo
1 Replies

6. Shell Programming and Scripting

Display find results, and pipe to xargs

I have an overnight script which runs across a large directory to repair permissions and ownership. I also have this command output the list of files affected so that cron can email these as a log file. Previously I had the command in the form: find /path/to/files -not -user myname -print -exec... (4 Replies)
Discussion started by: mij
4 Replies

7. UNIX for Dummies Questions & Answers

is there any way of using rm command on output of pipe

Hi, I am having a list of directories with different login id's. My requirement is that i need to list the directories of my id and need to delete them. So i am using following code ls -ltr ¦ grep userid ¦ rm -rf But this is not working. So is there any way of doing it. Please note... (3 Replies)
Discussion started by: sarbjit
3 Replies

8. Shell Programming and Scripting

Assign command (with pipe) output to a variable

Hi , I would like to assign command (with pipe) output to a variable. The code is as follows. The goal of the code is to get the last folder folder with a particular name pattern. myDate=`ls | grep 2009 | tail -1` echo "myDate=" $myDate However, in the presence of the pipe, the code... (3 Replies)
Discussion started by: jeff_cen
3 Replies

9. UNIX for Dummies Questions & Answers

pipe output to script as command line argument

i want to redirect output of one command as the command line argument of another script for example, say i would run this command: find . -xdev -type f -size +4096 -exec ls -al {} \; i wan to be able to do something like: echo +4096 | find . -xdev -type f -size ****** -exec... (3 Replies)
Discussion started by: IMTheNachoMan
3 Replies
Login or Register to Ask a Question