Need help with command to append strings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with command to append strings
# 1  
Old 07-04-2007
Need help with command to append strings

Greetings all,

I'm in need of some help in coming up with this command which requires me to append 5 strings together:

1. echo "Status from system:"
2. `cat logs.txt` (i need the output of this command)
3. echo "Error output: "
4. `cat errors.txt`(i need the output of this command)
5. echo "Thank you"

How can I append all five strings together? I'm interested in doing this and then piping the command over to mailx to construct my message body.

Thanks a bunch. Smilie
# 2  
Old 07-04-2007
What u can do this to form a temporary file which by appending all the statements from you 5 steps and then include the file as the body of the mailx command.

You can use like

cat letter.dat | mailx ...

Hope this helps
# 3  
Old 07-04-2007
Code:
{
   echo "Status from system:"
   cat logs.txt
   echo "Error output: "
   cat errors.txt
   echo "Thank you"
} | mailx ....

# 4  
Old 07-06-2007
or

Code:
mailx -vs "subject" blah@here.com <<EOF
results:
`cat res.ttxt`
errors:
`cat errors.txt`
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to append strings with whitespace?

Hi, Need help. This seems simple but I tried many things but failed to get what I wanted. Below is the input file: ... (7 Replies)
Discussion started by: bunny_merah19
7 Replies

2. Shell Programming and Scripting

Append your messaage in UNIX command

Hi All, I am executing this command to capture all the outputs from Error_*.txt files to all.txt file as a single output. head -n -5 Error_*.txt > all.txt It gives me the output in all.txt as: ==> ErrorLog_batchSearch.txt <== 2014-03-09 17:07:28,193 ERROR Cannot parse property value... (6 Replies)
Discussion started by: ankur328
6 Replies

3. Shell Programming and Scripting

Need to append matching strings in a file

Hi , I am writing a shell script to check pvsizes in linux box. # for i in `cat vgs1` > do > echo "########### $i ###########" > pvs|grep -i $i|awk '{print $2,$1,$5}'>pvs_$i > pvs|grep -i $i|awk '{print $1}'|while read a > do > fdisk -l $a|head -2|tail -1|awk '{print $2,$3}'>pvs_$i1 >... (3 Replies)
Discussion started by: nanduri
3 Replies

4. Shell Programming and Scripting

How to use variables in 'sed' append command?

HELLO!! I'm trying to pass a variable with in the 'sed' command (which would add some piece of code to file at a particular line). We can use sed '{line-number}a\ alfjaljf\ aslfjsfsjafl\ adlfjaf\' file.txt If file.txt is Now, I would like to add the parameter 'lmn' after... (1 Reply)
Discussion started by: mjavalkar
1 Replies

5. UNIX for Dummies Questions & Answers

Append command and strings to a text file

hi gurus, I'm executing some commands and I want to append both the command and output to a text file. Example: echo "strings -a wicmex.o|grep '$Header'" >> tmp.txt strings -a wicmex.o|grep '$Header' >> tmp.txt echo "strings -a libwip.a|grep '$Header'" >> tmp.txt strings -a libwip.a|grep... (1 Reply)
Discussion started by: donisback
1 Replies

6. Shell Programming and Scripting

How to append something to a word using sed command

Hi, How to append something to already existing word. Suppose, I have the following line as a part of a file. VVV= jdbc:... (6 Replies)
Discussion started by: Dpu
6 Replies

7. Shell Programming and Scripting

How to append some strings line by line?

I would like to append the numbers 1, 2, 3, 4 and so on to the lines of the file: Adam Wilkins | Colorado | 36 John Butler | Los Angeles | 47 Cassey Johnson | Minneapolis | 25 Albert Aniston | Miami | 19 .... Tony Legler | Sacramento | 55 Matt Simmons | New York | 38 Output would look... (4 Replies)
Discussion started by: xinoo
4 Replies

8. AIX

append file with tar command

hello, can i append files into tape without clear this tape thanks for help (3 Replies)
Discussion started by: mbakry23
3 Replies

9. UNIX for Dummies Questions & Answers

How to append "spaces" between strings

HI, Supose I have the folowing strings: "unix" and "linux". I want to concatenate the two strings, inserting between them a variable number of spaces. ex1: unix linux ex2: unix linux Can you help me in this simple problem? Regards, Elio (2 Replies)
Discussion started by: efernandes
2 Replies

10. UNIX for Dummies Questions & Answers

Append strings with filler spaces

Hi I am looping through the contents of a file as follows cat file |while read inrec do echo $inrec >> $TMP done (obviously this isn't all i am doing as it would be pointless but for the sake of the problem this is the important bit) The file has fields which are separated by... (1 Reply)
Discussion started by: handak9
1 Replies
Login or Register to Ask a Question