Append command and strings to a text file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Append command and strings to a text file
# 1  
Old 08-28-2012
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:
Code:
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 '$Header' >> tmp.txt

Is there any way where I can append both the command and output of the command to a text file?
# 2  
Old 08-28-2012
If you have the script command installed, it will create a subshell and save a transcript of the session in this shell.
 
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 to update file with partial matching line in another file and append text

In the awk below I am trying to cp and paste each matching line in f2 to $3 in f1 if $2 of f1 is in the line in f2 somewhere. There will always be a match (usually more then 1) and my actual data is much larger (several hundreds of lines) in both f1 and f2. When the line in f2 is pasted to $3 in... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

3. Shell Programming and Scripting

How to append a text file?

i have to append a text file grep for a word, if found, put comment in starting of the line. here is an example cat test.sh bin/ksh Hello World Test Message :wq! search for "bin" word in test.sh file if found comment it out at starting of the line: Output as follows: #bin/ksh... (5 Replies)
Discussion started by: raghur77
5 Replies

4. 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

5. Shell Programming and Scripting

Append Text in Result File Name

Hi Below command is returning the list of files which having this string "MTL_SYSTEM_ITEMS". find . -name "*"|xargs grep -il MTL_SYSTEM_ITEMS Ex: Above command is returing 2 files (Out of 10 files 2 files having this string). ./file1.txt and ./file2.txt Here I want to append... (3 Replies)
Discussion started by: balajiora
3 Replies

6. Shell Programming and Scripting

How to append text to the second line of a file

Say I have a text file like: 1 3 4 How would I use ksh to put the number '2' into the second line of that file? I'm using OpenBSD so the sed syntax might be a bit different (I have no idea how to use sed, though) (4 Replies)
Discussion started by: guitarscn
4 Replies

7. Shell Programming and Scripting

Script to append text from one file into another

Hello all. I was wondering if it possible to write a bash script that would do the following: I perform molecular modelling calculations and the output files are all text files with various different extensions. For example, I submit the input file "job_name.inp" and when it is done or the... (18 Replies)
Discussion started by: marcozd
18 Replies

8. UNIX for Dummies Questions & Answers

append a text to a file every month

i have something like below in my SAS code and every month i need to append a text say 'ext.hlc_sum0906' near ext.hlc_sum0905 and next month after ext.hlc_sum0906 i need to append this 'ext.hlc_sum0907' and so on like that.. is it possible using SED or some other command in unix? %let... (1 Reply)
Discussion started by: depakjan
1 Replies

9. Shell Programming and Scripting

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.... (3 Replies)
Discussion started by: rockysfr
3 Replies

10. Shell Programming and Scripting

how to append text into a file.

I have a command stream that will parse down an ftp DIR listing of a remote directory and return the name of the newest file that I am interested in. The command is sed -e '/^d/d' sppay.listing |sed -n -e '/SPPAY/p'|sort -r -k 43M,45 -k 47,48 -k 50,54|sed -n -e '1p'|cut -c 56-99 and what it... (2 Replies)
Discussion started by: beilstwh
2 Replies
Login or Register to Ask a Question