sed -i option giving error no such file or directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed -i option giving error no such file or directory
# 8  
Old 12-20-2012
OK. Here is what I have done:

File yes.txt (before):
Code:
yes
why
when
what

File yes.sh:
Code:
#!/bin/sh
sed -i 's/yes/no/' yes.txt
sed -i 's/why/where/' yes.txt
sed -i 's/when/how/' yes.txt

Made it executable:
Code:
chmod 754 ./yes.sh

Execute it:
Code:
./yes.sh

File yes.txt (after):
Code:
no
where
how
what

I'm happily using LinuxMint while it gets updated as needed, so I guess it is version 14 by now... Hope this helps.
# 9  
Old 12-20-2012
Thanks for your reply!!!

Anyone using cygwin can please confirm if it works
# 10  
Old 12-20-2012
Why don't you add a pwd and an ls -l to your script so you can see where it looks for the file yes.txt?
# 11  
Old 12-21-2012
Why don't it works in CYGWIN. See my output from Cygwin screen

Code:
# cat > yes.txt
yes
why
when
what



# cat > yes.sh
#!/bin/sh
sed -i 's/yes/no/' yes.txt
sed -i 's/why/where/' yes.txt
sed -i 's/when/how/' yes.txt



# chmod 754 ./yes.sh


# ./yes.sh


# cat yes.txt
no
where
how
what

Please share us your error output...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replace is giving me sore thumbs

I want to replace only the exact match of string inside the file with another value during the run time. So, I have a file filename.txt where contents are: version="1.0.7", url="https://google.com/_api/version=GBMaster" now in my script I have variable and tried to replace the... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

2. AIX

Opening a file in vi editor is giving out of memory error

Below is the error: Out of memory saving lines for undo - try using ed : Please help me how do I open this file. Best regards, Vishal (5 Replies)
Discussion started by: Vishal_dba
5 Replies

3. UNIX for Dummies Questions & Answers

What option will use for deleting directory with all its contents?

Hi How to completely delete directory with all it contents I try to use rmdir -r but it give error Thanks ---------- Post updated at 03:10 AM ---------- Previous update was at 02:52 AM ---------- Hi all I got the solution for my thread i use mkdir with the option -p Thanks (1 Reply)
Discussion started by: Tauatioti
1 Replies

4. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

5. Shell Programming and Scripting

sed -n option

Hi i am facing problem with sed -n option could you please help me on this, i have a file test the contents of the file is width="75">10/0 4/12</td>^M><a href='courtorders/100412zr.pdf' target="_blank">Miscellaneous Order</a></td>^M width="75">10/01/12</td>^M><a href='courtorde... (8 Replies)
Discussion started by: ragilla
8 Replies

6. Shell Programming and Scripting

Sed in vi - \r and \n not giving desired results

I use many different machines at work, each with different versions of o/s's and installed applications. Sed in vi is particularly inconvenient in the sense that sometimes it will accept the "\r" as a carriage return, sometimes not. Same thing with "\n". For instance, if I have a list of hosts... (7 Replies)
Discussion started by: MaindotC
7 Replies

7. UNIX for Dummies Questions & Answers

sed -i option example

Can anyone give detailed and example for sed -i option. Where can we use this option?:) (3 Replies)
Discussion started by: gwgreen1
3 Replies

8. Shell Programming and Scripting

Read/Search file being written to giving error due to timing issues

The following is a piece of code to rename LOG_FILE_NEW to LOG_FILE once you get a result (either RUNNING or SHUTDOWN) RESULT="" sleep 30 while ; do sleep 10 RESULT=`sed -n '/RUNNING/'p ${LOG_FILE_NEW}` if ; then RESULT=`sed -n '/SHUTTING_DOWN/'p ${LOG_FILE_NEW}` fi done mv... (3 Replies)
Discussion started by: sonorous
3 Replies

9. Solaris

giving write access to selective users to a certain directory in solaris 10

Hi all, how can i grant write access to a selective users only with write access to a certain filesystem/directory in solaris 10. Please help..i tried "fs setacl"...does not seem to work Please adv..thanks in advance... (4 Replies)
Discussion started by: cromohawk
4 Replies

10. UNIX for Dummies Questions & Answers

sed option to delete two words within a file

Could someone please help me with the following. I'm trying to figure out how to delete two words within a specific file using sed. The two words are directory and named. I have tried the following: sed '//d' sedfile sed '//d' sedfile both of these options do not work..... ... (4 Replies)
Discussion started by: klannon
4 Replies
Login or Register to Ask a Question