![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| xargs problem | encrypted | Shell Programming and Scripting | 3 | 05-16-2009 12:15 PM |
| Question concerning xargs | cp27316 | UNIX for Dummies Questions & Answers | 4 | 03-13-2007 11:30 PM |
| xargs doubt | shihabvk | Shell Programming and Scripting | 1 | 09-29-2005 10:38 AM |
| find | xargs cat | asal_email | Shell Programming and Scripting | 4 | 03-17-2005 12:16 AM |
| Help with xargs | JimJim | UNIX for Dummies Questions & Answers | 4 | 02-08-2005 07:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
xargs
Can I use xargs to send a list of commands to a process, to be acted upon individually? Here's what I have: a file that contains numbers, one per line. The desired outcome it to send each number to a DB2 query. I thought xargs would work, but it doesn't. I tried it like this:
cat file | xargs | db2 "select * from table where field = $*" Can this work somehow? thanks |
|
|||||
|
xargs would not be my first choice for something like this, but it can certainly be made work. I don't know what the db command is and looking at your syntax, I can't tell where the arg should be inserted, but here is an example using echo:
cat file | xargs -l -i echo "arg is {}" and even better: xargs -l -i echo "arg is {}" < file Hmmm, I gotta admit that using xargs in a case like this is starting to appeal to me... |
|
||||
|
xargs works
Thanks everyone. I did get it to work, using xargs with the -n1
option. file1 is just a list of numbers, one per line: 1234455 7778889 cat file1 | xargs -n1 "db2 select * from table1 where field1 in ('$*')" |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|