Xargs: multiple commands to each argument


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Xargs: multiple commands to each argument
# 1  
Old 03-01-2015
Xargs: multiple commands to each argument

Hello. There is my one-liner to get subjects of potential spam mails
Code:
sudo exiqgrep -bf "spamer@example.com" |cut -d' ' -f1 |xargs -I ~ sudo /usr/sbin/exim -Mvh ~ |grep 'Subject: '

I want to insert blank line after each iteration to make output more readable. I tried
Code:
sudo exiqgrep -bf "spamer@example.com" |cut -d' ' -f1 |xargs -I ~ sudo /usr/sbin/exim -Mvh ~ |grep 'Subject: ' && echo ""
sudo exiqgrep -bf "spamer@example.com" |cut -d' ' -f1 |xargs -I ~ echo "" && sudo /usr/sbin/exim -Mvh ~ |grep 'Subject: '
sudo exiqgrep -bf "spamer@example.com" |cut -d' ' -f1 |xargs -I ~ sh -c "echo \"\"; sudo /usr/sbin/exim -Mvh ~ |grep 'Subject: '"

Please advice.
# 2  
Old 03-02-2015
Instead of grep, you can use awk?

I mean instead of
Code:
grep 'Subject: '

use
Code:
awk '/Subject: / {print $0"\n"}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Xargs to call python executable to process multiple bam files

I am running the below loop that to process the 3 bam files (which isn't always the case). A .py executable is then called using | xargs sh to further process. If I just run it with echo the output is fine and expected, however when | xargs sh is added I get the error. I tried adding | xargs... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. UNIX for Beginners Questions & Answers

Piping commands using xargs

Need help in piping commands using xargs I have several .tar.gz files that I need to list the folder content in a subdirectory. For example, a.tar.gz b.tar.gz c.tar.gz The following command works great for each .tar.gz file but it's a pain to run the tar command for each file. tar -tf... (11 Replies)
Discussion started by: april
11 Replies

3. UNIX for Advanced & Expert Users

Pass Multiple Commands and Open Multiple Xterms via PSS

Hello, I'm attempting to open multiple xterms and run a command as an SAP user via sudo using PSSH. So far, I'm able to run PSSH to a file of servers with no check for keys, open every xterm in to the servers in the file list, and SUDO to the SAP(ADM) user, but it won't do anything else... (11 Replies)
Discussion started by: icemanj
11 Replies

4. Shell Programming and Scripting

Xargs error: insufficient space for argument

I'm trying to crudely hack my way through some data processing. I have file.txt with around 17,000 lines like this: ACYPI002690-PA.aa.afa.afa.trim_phyml_tree_fullnames_fullhomolog.txt 3 72 71 ACYPI002690-PA.aa.afa.afa.trim_phyml_tree_fullnames_fullhomolog.txt 97 111 71... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

5. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

6. UNIX for Dummies Questions & Answers

grep -v with multiple argument

Hi, I want to grep ORA-XXX errors in a file but not ORA-16055: FAL request rejected ORA-16401: archivelog rejected by RFS ORA-16040: ORA-12154 Then I thought of grep -v ORA-16055 ORA-16401 ORA-16040 ORA-12154 myfile that does not work. Any solution ? (other than : grep -v... (1 Reply)
Discussion started by: big123456
1 Replies

7. Shell Programming and Scripting

Using xargs for multiple functions

Hi Experts, I am trying to parse some syslog outputs into a separate file per node using the below syntax but am having issues when it comes to my Xargs statements. The command which I was intending on using was: cat syslogs | nawk '/From/ { print $3 }' | uniq | xargs -I {} grep {}... (5 Replies)
Discussion started by: krypton
5 Replies

8. Shell Programming and Scripting

Can Xargs execute multiple commands of evry input file

Hello , I am trying to print the footer of evry file in the given directory with xargs command like follows ls -1 | xargs -I {} gzcat {} | tail -1 now problem with this is only last file foooter is getting printed as " | tail -1 " is getting executed for the last file. I know this can... (4 Replies)
Discussion started by: nilesrex
4 Replies

9. UNIX for Dummies Questions & Answers

1 alias 2 commands 1 argument

Hi, i want make 1 alias with two commands include to do two things at the same time like this: ex: do finger and last at the same time with only one word finla or something. Thanks.- /home/seba > finger dustin Login name: dustin In real life: Dustin Feldman Directory:... (3 Replies)
Discussion started by: seba
3 Replies

10. UNIX for Dummies Questions & Answers

Executing commands with xargs

I have a SQL script that requires values from the environment in order to execute. I found a way to get the desired results but my process is a little choppy. Any suggestions on how to clean this up would be greatly appreciated. SQL Script ------------- select a, b, c from d where a =... (1 Reply)
Discussion started by: bmopal
1 Replies
Login or Register to Ask a Question