Replace last line of file in memory via embedded command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace last line of file in memory via embedded command?
# 1  
Old 10-17-2010
Replace last line of file in memory via embedded command?

Further to my earlier question regarding embedded commands I now want to delete then replace the last line in a file in memory....

Code:
FILEHERE=$((echo "$FILEHERE" | sed -e '$d' ) echo "this now added")

this is throwing a syntax error but as I'm still getting used to this structure I don't know the best place to look for reference material on it (googling bash embedded command doesn't help)

Thanks in advance.
# 2  
Old 10-17-2010
This should work
Code:
FILEHERE="$(echo "$FILEHERE" | sed '$d')
this now added"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Centos server, had to replace the motherboard now the embedded NICs don't work

Basically what the title says. Had to replace the motherboard on an HP DL380 G6 today, of course now the embedded NICs don't work because the ifcfg-eth files have the MAC addresses for the embedded NICs from the old machine. How can I find the new/correct MAC addresses so I can edit the... (2 Replies)
Discussion started by: xdawg
2 Replies

2. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

3. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

HI Can any one guide me how to achieve this task. I have 2 files env.txt #Configuration.Properties values identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register randon_password_length = 6 attachment_file_path = /pass/temp/attachments/... (1 Reply)
Discussion started by: nikilbr86
1 Replies

4. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies

5. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

6. Shell Programming and Scripting

how to replace html line into a command line?

hi! i'm trying to use sed for this, but i'm struggling a lot. i want to convert <div class="middle" id="middle">Friday, 20 April 2012<br /> <span class="hex">728CB5</span> <br /></div> into fbsetroot -solid '#728CB5' considering all information between 'id="middle">' and '<br />... (2 Replies)
Discussion started by: nitrofurano
2 Replies

7. UNIX for Dummies Questions & Answers

How to search and replace a particular line in file with sed command

Hello, I have a file and in that, I want to search for a aprticular word and then replace another word in the same line with something else. Example: In file abc.txt, there is a line <host oa_var="s_hostname">test</host> I want to search with s_hostname text and then replace test with... (2 Replies)
Discussion started by: sshah1001
2 Replies

8. UNIX for Dummies Questions & Answers

find and replace command in one line using one command

Hi, I have a entry in the file as ::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995 if u see this, i have the delimiter as :: , all i want is to replace "::" as ":" so how to do that.. pls help thanks (10 Replies)
Discussion started by: vasikaran
10 Replies

9. Shell Programming and Scripting

how can i extract only the Memory line from top command ?

Hello all i need in csh to extract only the Memory line from the out put of the top command how can it easily done (1 Reply)
Discussion started by: umen
1 Replies

10. UNIX for Dummies Questions & Answers

replace text in a file from the command line...

I am having to do a lot of searching thru files to replace words. Is there a command that i can run that will alow me to hunt thru a group of files and replace one word with another without having to open each file idividually? -thanks;) (1 Reply)
Discussion started by: dudboy
1 Replies
Login or Register to Ask a Question