Output in separate files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output in separate files
# 1  
Old 02-04-2015
Linux Output in separate files

Hi all,

i have the bash script for remote conection,

Code:
for hosts in $(cat /list);  do
       ssh user1@$hosts "hostname";
done

execute hostname command by all hosts and show standar ouput,

how i can send to file by each host in lists, so

e.g.

Code:
$cat list
10.0.0.1
10.0.0.2
10.0.0.3

afeter execute script create separate files file1, file3 file3

Code:
$cat file1
machine1

$cat file2
machine2

$cat file3
machine3


Thansk you,

Last edited by Corona688; 02-04-2015 at 01:47 PM..
# 2  
Old 02-04-2015
Redirect ssh's output to "file${hosts##*.}" .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Awk: output lines with common field to separate files

Hi, A beginner one. my input.tab (tab-separated): h1 h2 h3 h4 h5 item1 grpA 2 3 customer1 item2 grpB 4 6 customer1 item3 grpA 5 9 customer1 item4 grpA 0 0 customer2 item5 grpA 9 1 customer2 objective: output a file for each customer ($5) with the item number ($1) only if $2 matches... (2 Replies)
Discussion started by: beca123456
2 Replies

2. Shell Programming and Scripting

awk to create separate files but not include specific field in output

I am trying to use awk to create (in this example) 3 seperate text file from the unique id in $1 in file, if it starts with the pattern aa. The contents of each row is used to populate each text file except for $1 which is not needed. It seems I am close but not quite get there. Thank you :). ... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Trying to use diff output to compare to a separate file

I have two files: smw:/working/iso_testing # cat a QConvergeConsoleCLI-1.1.03-49.x86_64.rpm aaa_base-13.2+git20140911.61c1681-1.3.i586.rpm acpica-20140724-2.1.2.i586.rpm test.rpm smw:/working/iso_testing # cat b QConvergeConsoleCLI-1.1.03-49.x86_64.rpm... (12 Replies)
Discussion started by: jedlund21
12 Replies

4. Shell Programming and Scripting

Single grep to multiple strings with separate output per string

I need to grep multiple strings from a particular file. I found the use of egrep "String1|String2|String3" file.txt | wc-l Now what I'm really after is that I need to separate word count per each string found. I am trying to keep it to use the grep only 1 time. Can you guys help ? ... (9 Replies)
Discussion started by: nms
9 Replies

5. Shell Programming and Scripting

Separate output based on dates

Hi guys! First time poster on here, was wondering if someone could help with a problem which I'm facing. Is it possible to use awk or sed to separate the below output based on TRANSACTION_DATE? The output would then feed into DataStage. Contents of CSV file:... (5 Replies)
Discussion started by: Jimmy_the_tulip
5 Replies

6. Shell Programming and Scripting

extract DDL - output every match to separate file

Hi, i want to extract the 'CREATE INDEX' or 'CREATE UNIQUE INDEX' statements from a ddl file and output each match to a separate file. i was looking around the net but couldnīt find anything. a possible sed-script could be: sed -n '/CREATE*INDEX*/,/COMMIT/p' filename.ddlbut i couldnīt find out... (11 Replies)
Discussion started by: CactusMoon
11 Replies

7. Shell Programming and Scripting

Want to separate my /var/adm/messages output

Hi, Please help to seprate my /var/adm/messages output. Than i want to take this output in the excel. e,g cat /var/adm/messages Sep 4 10:16:52 ibsadm1 inetd: vnetd from 172.17.5.20 38353 Sep 4 10:16:52 ibsadm1 inetd: bpcd from 172.17.5.20 915 Sep 4 10:16:55 ibsadm1 inetd: ... (5 Replies)
Discussion started by: nirjhar17
5 Replies

8. UNIX for Dummies Questions & Answers

awk to match multiple regex and create separate output files

Howdy Folks, I have a list that looks like this: (file2.txt) AAA BBB CCC DDD and there are 24 of these short words. I am matching these patterns to another file with 755795 lines (file1.txt). I have this code for matching: awk -v f2=file2.txt ' BEGIN { while(... (2 Replies)
Discussion started by: heecha
2 Replies

9. Shell Programming and Scripting

extract nth line of all files and print in output file on separate lines.

Hello UNIX experts, I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines. e.g. The input Files are one.txt, two.txt, three.txt, four.txt The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies

10. UNIX for Dummies Questions & Answers

Output of command to 2 separate file?

How would I echo the same results to two files? One is a running log, and the other is a cache, or sort. echo "Hello World" >> /Logs/File1 & /tmp/file2 I would just copy it from one place to the other, but the Log keeps history, where I want the /tmp to hold only stuff per session. I tried... (2 Replies)
Discussion started by: TheCrunge
2 Replies
Login or Register to Ask a Question