Appending something to output before being written to a file

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Appending something to output before being written to a file
# 1  
Old 09-05-2009
Appending something to output before being written to a file


I'm quite stuck with what I thought should've been simple but I just can't seem to do it. Firstly, I have the following done in bourne shell:
cat datafile | tr '[a-z]' '[A-Z]' >> newfile
echo "$fullfilepath" >> newfile

i want to have the output of that echo put on the same line as the output from cat datafile | tr '[a-z]' '[A-Z]' as it puts it in newfile, but i cannot find anyway to add the echo output onto the same line, only as the next line, such as "OUTPUT FROM THE FIRST LINE-/echo/output/here" inside the newfile, so far I've only been able to put the echo data onto a separate line as shown from the code above
# 2  
Old 09-05-2009
sed -i '$s/$/'"$fullfilepath"'/' newfile

# 3  
Old 09-05-2009
Another way:

cat datafile | tr '[a-z]' '[A-Z]' | while read RECORD
       echo "${RECORD}-${fullpath}"
done > newfile

# 4  
Old 09-05-2009
Yet some more ways:

cat datafile | tr '[a-z]' '[A-Z]' |sed -e 's#$#-'$fullfilepath'#' >> newfile

tr '[a-z]' '[A-Z]' <datafile |sed -e 's#$#-'$fullfilepath'#' >> newfile

sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;s#$#-'$fullfilepath'#' datafile >> newfile

awk '{print toupper($n)"-" fp}' fp=$fullfilepath datafile >> newfile

# 5  
Old 09-06-2009
(post deleted)

Last edited by methyl; 09-06-2009 at 04:52 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending output to file

Hi, I want to calculate std dev for a list of files and then print the output appended to an existing file. I have a few folders within the directory Folder, and I am interested in getting the std dev of values in files named as time.txt. In the last pipe, if I print just the sd value, it... (1 Reply)
Discussion started by: jamie_123
1 Replies

2. UNIX for Dummies Questions & Answers

12. If an ‘88’ Record with BAI Code ‘902’ was found on input file and not written to Output file, re

This is my input file like this 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/ 49,+00000000000416920,00002/ 03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/ 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/ 88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies

3. Shell Programming and Scripting

Appending script output to file

Hi guys, I have a script from which I would like its standard output results (upon execution) to be appended to a separate file (.txt format). How can I write such a command into the script for this to occur? I know there should be a >> involved somewhere. Thanks! (5 Replies)
Discussion started by: jjb1989
5 Replies

4. UNIX for Dummies Questions & Answers

Appending sed output to variable

I want to append matched output and cat the results into an variable. but I've been running into problems. sed is printing result on to screen instead of appending the output to $CAPTURE. I'm should i fix this? contents of $TEST expected... (5 Replies)
Discussion started by: jazzaddict
5 Replies

5. Shell Programming and Scripting

Appending process output into a file

Hello Friends, I'm trying to save process status of root user sorting by CPU usage. However i couldnt save the continuous, standard outputs into a file. Do you have any idea to do it? prstat -u root -a -s cpu | sed -e '/^$/d;/sleep/d;/Total/d' >> stat.txt >ls -l stat.txt -rw-r--r-- 1... (1 Reply)
Discussion started by: EAGL€
1 Replies

6. UNIX for Dummies Questions & Answers

output of file from several machines written to network share, then emailed to group.

I have a script on all the machines on my network that lists how many updates are available for each machine, and then outputs the answer to a file called updates.txt the output shows the hostname and the number of updates, like: computer_A 7 I want all these machines to output the data to... (1 Reply)
Discussion started by: glev2005
1 Replies

7. Shell Programming and Scripting

capturing line from script output and appending to a file

Hi all, I did some searching in this forum but can't find anything that matches the issue I'm bumping heads with. On a CentOS4/Postfix (and bash everywhere) mail gateway box I run a command periodically to purge the Postfix queue of messages "From:MAILER-DAEMON". This is the one line'r... (6 Replies)
Discussion started by: wally_welder
6 Replies

8. Shell Programming and Scripting

appending to sed output of one file into the middle of file

hi, i have a file file1 file2 ----------- ----------------- aa bbb ccc 111 1111 1111 ddd eee fff 222 3333 4444 ggg hhh... (5 Replies)
Discussion started by: go4desperado
5 Replies

9. Programming

ld: fatal: Symbol referencing errors. No output written to SNX

Hi all, I am getting the following error when I try to do a build of a product. I dont have the dependencies of the binaries involved in the build and thats the reason I was not able to find which library to add or to proceed to the next step to solve the reference problem. Undefined ... (1 Reply)
Discussion started by: jerryragland
1 Replies
Login or Register to Ask a Question