How to append using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to append using sed
# 1  
Old 08-24-2009
How to append using sed

Hello all,

I want to use sed to append a variable stored in $i, how do i do that?
$i contains a path to a directory and i want to append it before the result i get from awk statement, before affecting awk results.

rite now out put i get from code below is:-

Code:
The path is: /net/icebox/vol/local_images/spins/7.1/CQ/7.1.D081110/
basement.sun5 
msgcat.JPN.sun5
perl.sun5
CMServer.CQ.sun5

Output desired:-

Code:
The path is: /net/icebox/vol/local_images/spins/7.1/CQ/7.1.D081110/
basement.sun5   /net/icebox/vol/local_images/spins/7.1/CQ/7.1.D081110/
msgcat.JPN.sun5  /net/icebox/vol/local_images/spins/7.1/CQ/7.1.D081110/ 
perl.sun5  /net/icebox/vol/local_images/spins/7.1/CQ/7.1.D081110/ 
CMServer.CQ.sun5   /net/icebox/vol/local_images/spins/7.1/CQ/7.1.D081110/

Code:
check_sun() {
for i in $SUN_PLATFORM
do
$ECHO "The path is: " $i
$LS $i | $GREP .su |  $AWK -F"_" '{print $1}'
done
}


Thanks
Adsi

Last edited by vgersh99; 08-24-2009 at 11:35 AM.. Reason: code tags, PLEASE!
# 2  
Old 08-24-2009
Code:
$LS $i | $GREP .su |  $AWK -F"_" '{print $1, path}' path="${i}"

# 3  
Old 08-24-2009
Thanks, that worked
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed append without using new line

im trying to append to the end of the line using sed but I want to do it without creating a new line the text to which I want to append is all in capital letters. I want to do something like this: LINE]Foo but when I do this: //a\ ] Foo it prints foo on a new line: LINE ]Foo ... (11 Replies)
Discussion started by: mrjavoman
11 Replies

2. Shell Programming and Scripting

sed append to string

I am trying to replace in multiple files every instance of text that begins with http and add hyperlink characters to it. I can get it to work with the following:sed -e "s/http*.*/<a href=\"&\">&<\/a>/g" * as long as the http text is at the end of the file. I need it to stop at the end of the... (2 Replies)
Discussion started by: numele
2 Replies

3. Shell Programming and Scripting

How to append line with sed?

Input: gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly Output should be: gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly How can it be done with sed? (5 Replies)
Discussion started by: cola
5 Replies

4. Shell Programming and Scripting

sed append words

Hi all, I have a file like one two three for five six seven eight ..... Actually i need to append a label to the words that belong to the 2 column and get: one two_label three for five six_label seven eight .... I was trying with sed inside vim but I can't figure out... (9 Replies)
Discussion started by: Dedalus
9 Replies

5. Shell Programming and Scripting

Append using SED/AWK

Hi friends, I have a file with content SOME TEXT HERE I want to append the string GREAT to Line 1 of my file such that the file content should be GREAT SOME TEXT HERE I can do a cat for the string great and file >> newfile and then rename newfile name to file But this does not put... (5 Replies)
Discussion started by: dahlia84
5 Replies

6. Shell Programming and Scripting

sed append in first column

hi, anyone can give a sample command on sed. the text file date list belows; test.txt "a","bbb",123 "b","ccc",234 "c","eee",456 output i need to add these word "xxx" "xxx","a","bbb",123 "xxx","b","ccc",234 "xxx" ,"c","eee",456 thanks in advance, FSP (4 Replies)
Discussion started by: fspalero
4 Replies

7. Shell Programming and Scripting

Append lines with SED

I have the following data in a file and would like to append the lines inside each section 10, 20, 30, 40, etc... onto one line for each of the sections. Is it possible with SED to make this happen?? 10 00039393 DOCK: RECEIVE PART, TAG. D D ... (3 Replies)
Discussion started by: miklacic
3 Replies

8. Shell Programming and Scripting

replace and append using SED

Hi, i need to replace hyphen with underscore in a string and also append some text before it. e.g. if the string is 130707-abc-123.txt then it has to be made UB130707_abc_123.txt. Also, need help on how to do it on many strings exist in a file. I know it can be done by using sed but it... (4 Replies)
Discussion started by: prvnrk
4 Replies

9. UNIX for Dummies Questions & Answers

Sed: Append and Delete?

I think it should be obvious what I'm trying to do from my command, but just to be sure it's clear, I'm trying to append 2 lines after a matched line and then delete 2 other lines within a file. I'd like to do it in 1 line if possible. This code isn't working, but hopefully it's just a syntax... (0 Replies)
Discussion started by: earnstaf
0 Replies

10. Shell Programming and Scripting

append to fle using sed

Hello , I have the folloiwing command : sed -n "$var,$final w $destfile" $sourcefile where : $var - $final represent the range of line numbers to be written in $destfile However I require this command to work in a loop for which i need the sed command to keep appending the output to the... (2 Replies)
Discussion started by: shweta_d
2 Replies
Login or Register to Ask a Question