sed command works from cmd line to standard output but will not write to file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command works from cmd line to standard output but will not write to file
# 1  
Old 08-30-2010
sed command works from cmd line to standard output but will not write to file

Hi all .... vexing problem here ...

I am using sed to replace some special characters in a .txt file:

sed -e 's/_<ED>_/_355_/g;s/_<F3>_/_363_/g;s/_<E1>_/_341_/g' filename.txt

This command replaces <ED> with , <F3> with and <E1> with .

When I run the command to standard output, it works as expected.

When I attempt to write to another file, the special characters are eliminated again.

sed -e 's/_<ED>_/_355_/g;s/_<F3>_/_363_/g;s/_<E1>_/_341_/g' filename.txt

works, but

sed -e 's/_<ED>_/_355_/g;s/_<F3>_/_363_/g;s/_<E1>_/_341_/g' filename.txt>filename2.txt

does not.

any help is appreciated.
# 2  
Old 09-01-2010

more info:

when I run this command on a 5.9 Solaris server it works as expected.

The problem exists only on 5.10 Solaris instances.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

3. Windows & DOS: Issues & Discussions

Command works on CMD line but not in batch?

Hi All, This command works when I type it on but when I run the batch file it doesn't..any ideas why? attrib.exe * | find /c /v "" >filecount.txt (1 Reply)
Discussion started by: Grueben
1 Replies

4. Shell Programming and Scripting

Appending standard C Time on each line out output

I have a command : nawk 'BEGIN{print srand()}' which gives the amount of seconds between January 1st 1970 00:00:00 (Unix Epoch) and the present time, to the closest second and I would want to append this time stamp every minute in a file which contains the data below which also has one row... (1 Reply)
Discussion started by: thinktank
1 Replies

5. UNIX for Advanced & Expert Users

SSH key works from CMD line not script

OK , .. This is an odd one. I have a new server and I need to have a tunnel open to it. I have this exact process running on a few others but this new one I just got is not allowing the script to connect. I set up my users account and ssh keys from the server that will host the tunneling i... (6 Replies)
Discussion started by: jeffsandman0035
6 Replies

6. Shell Programming and Scripting

Command Output to Standard Input

Hi All, How do I provide the output of a command to another command which is waiting for an input from the user ? Ex : I need to login to a device via telnet. In the script, initially I use the "read" command to get the IP Address, Username and Password of the device from the user. Now,... (1 Reply)
Discussion started by: sushant172
1 Replies

7. Shell Programming and Scripting

Sed does not make changes in the file but to the standard output

I have an xml file. I am doing some change, say deleting line 770. File name is file.xml. I use: sed '770d' file.xml but this does not actually make changes in the *file* but shows the changes on standard output (screen) if i use $var=`sed '770d' file.xml` echo $var > file.xml this... (3 Replies)
Discussion started by: indianjassi
3 Replies

8. Shell Programming and Scripting

write page source to standard output

I'm new to PERL, but I want to take the page source and write it to a file or standard output. I used as a test website. Here is the script: use strict; use warnings; use LWP::Simple; getprint('') or die 'Unable to get page'; exit 0; ... (1 Reply)
Discussion started by: wxornot
1 Replies

9. Shell Programming and Scripting

works from cmd-line but not in script

hi I'm trying to query a directory, check it's the right directory, return the results into a text file, put text file into an array and navigate the subdirectories and delete contents. find `pwd` -type d | grep TESTINGDIR > dirList.txt The txt file is created from the cmd-line but not in... (4 Replies)
Discussion started by: OFFSIHR
4 Replies

10. Shell Programming and Scripting

Can I avoid the standard output from kill command

I am sending a kill comand to kill a process inside a SH script but I don`t want the user to notice it so I dont want the message "1222 killed" to appear. I`ve tried to redirect the standard output to /dev/null 2>&1 and also tried to use "nohup" but none of them was succesfull. Can anyone... (1 Reply)
Discussion started by: pguinal
1 Replies
Login or Register to Ask a Question

Featured Tech Videos