Redirecting echo output to 2 flat files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirecting echo output to 2 flat files
# 1  
Old 08-06-2008
Redirecting echo output to 2 flat files

Hello all,

I have the following 2 questions..

1) I would like to capture the output of an echo command to 2 different files at the same time. This does not seem to work. Any ideas?

echo ==== started on `date` ==== >> res1.log res2.log


2) Would it be possible to just get the 5th and 6th column of df -k output as listed below?

use% Mounted on

10 /d1
20 /d2

Thanks
# 2  
Old 08-06-2008
Quote:
2) Would it be possible to just get the 5th and 6th column of df -k output as listed below?
Use awk to get it.
Code:
df -k | awk '{ print $5 "  " $6}'

Quote:
1) I would like to capture the output of an echo command to 2 different files at the same time. This does not seem to work. Any ideas?
What you want capture in 2 different files ?
You can use for loop with 2 iterations to echo to 2 different files.

- nilesh
# 3  
Old 08-06-2008
Thanks Ynilesh for the quick response..I already tried using awk but as my df output is slightly different, I don't get the expected output as some of the FileSystem names are slightly longer.

df -k

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
10157368 972328 8660752 11% /
/dev/sda3 248895 18257 217786 8% /boot
tmpfs 33028244 0 33028244 0% /dev/shm
/dev/sda5 10153988 154352 9475520 2% /home
/dev/sda7 10153988 154928 9474944 2% /opt
/dev/sda6 10153988 157852 9472020 2% /tmp
/dev/sda9 10153988 4591136 5038736 48% /usr
/dev/sda8 10153988 325752 9304120 4% /var
/dev/mapper/VolApp-App
102180192 10133068 86856676 11% /app
/dev/mapper/VolDB-IOLDevData
411817200 297404052 93494060 77% /d1
/dev/mapper/VolDBbkp-IOLDevbkp
102180192 192264 96797480 1% /d15



df -k | awk '{ print $5 " " $6}'

Use% Mounted

/
8% /boot
0% /dev/shm
2% /home
2% /opt
2% /tmp
48% /usr
4% /var

/app

/d1

/d15
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting the results to different output files

Hi All, I am trying a shell script and need your help on taking the results to different output files. I have tried the below code: nawk ' {CNF = (length()-10)/7 printf "%9s", substr ($0, 1, 9) for (i=0; i<=CNF; i++) T = substr ($0, 10+i*7, 7) TMP = 100 - (T + T + T + T + T + T + T + T... (24 Replies)
Discussion started by: am24
24 Replies

2. Shell Programming and Scripting

Awk: Print Error While Redirecting output in multiple Files

Hi, I have a following code in which I am unable to redirect to multiple files. Can anybody please help with some corrections awk -F, '{ if ( substr($1,26,2)=="02" && substr($1,184,14)=="MTSCC_VALFIRST") { array1++ array2++ array3++ } else if (substr($1,26,2)=="03" &&... (4 Replies)
Discussion started by: siramitsharma
4 Replies

3. Post Here to Contact Site Administrators and Moderators

Redirecting grep output to multiple files

Hi All, I am trying to redirect the grep output to multiple files, can you please help with that. Below is the command im using to match my pattern grep \<proxyType\>$PxyType $DIR/EndureFiles.json > File_Name*.json Note : $DIR and $PxyType is already defined in my script Im able... (0 Replies)
Discussion started by: Deena1984
0 Replies

4. Shell Programming and Scripting

Redirecting the output

For example, if we run the below command, symcfg list -thin -pool , results in an output most of the times and if the out is generated i'm able to redirect the output to a file. but sometimes it doesnt result any output and even though the output is being redirected, i can see "No Thin Pools "... (2 Replies)
Discussion started by: web2moha
2 Replies

5. Shell Programming and Scripting

Echo prompt and redirecting the output to a file

Hi Help, I have a script which looks like below. echo "Train count??" set train_count = $< cat tmp | awk -v var=${train_count} '{print $0"var"}' > tmp The echo "Train Count??" does not show up in the terminal due to redirecting to output file tmp. How is it possible to have the prompt... (3 Replies)
Discussion started by: Indra2011
3 Replies

6. Shell Programming and Scripting

awk to compare flat files and print output to another file

Hello, I am strugling from quite a some time to compare flat files with over 1 million records could anyone please help me. I want to compare two pipe delimited flat files, file1 with file2 and output the unmatched rows from file2 in file3 Sample File1: ... (9 Replies)
Discussion started by: suhaeb
9 Replies

7. Shell Programming and Scripting

Redirecting to different output files with awk.

Well, it didn't take me long to get stumped again. I assure you that I'm not mentally deficient, just new to scripting. So, here's the gist. I want to redirect output from awk based off of which branch of an if-else statement under which it falls. #!/bin/bash #some variables... (2 Replies)
Discussion started by: mikesimone
2 Replies

8. Programming

execl() + redirecting output to text files

Im currently using execl() to run the ls command and redirect the output to a text file. Unfortunately, when I check the text file, no information has been written to it. I am calling execl() with the ls command like this execl( "/bin/ls" , "-al" , '>' , "dirlist.txt" ,(char *) 0 ); ... (5 Replies)
Discussion started by: JamesGoh
5 Replies

9. Shell Programming and Scripting

Redirecting OUTPUT

Hi, I want to move the output of a command/script to a file as well as to to be displayed on stdout. Can anybody help me in this. Thanks in advace .. -Chanakya M (1 Reply)
Discussion started by: Chanakya.m
1 Replies

10. UNIX for Dummies Questions & Answers

Redirecting output to multiple log files?

If I wanted to redirect output to multiple log files, what would be the best way to do that? echo "Unix is awesome" >>unixgod.log >>unixgod.log (3 Replies)
Discussion started by: darthur
3 Replies
Login or Register to Ask a Question