LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-02-2005, 04:02 PM   #1
lbauer
LQ Newbie
 
Registered: Mar 2005
Distribution: Mac with X11
Posts: 3

Rep: Reputation: 0
Sed command in file not working


I've got a little sed project for class.

When I run
s/'somename at domain.edu'/'lbauer@domain,edu'/g

this works fine from the command line and the substitution is made. But when I run it from a script in a file it doesn't work -- there's no substitution.
I even made it the only line in the file, copied and pasted from the command
I ran at the command line.

Is there a difference between results when you run from the command line vs a command within a file? Most of my other commands seem to be working.
 
Old 04-03-2005, 09:48 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Is there a difference between results when you run from the command line vs a command within a file?
There should be no difference, please post your script to clarify.
 
Old 04-06-2005, 05:50 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,283

Rep: Reputation: 172Reputation: 172
btw, you don't need the
quote marks within the ///

Code:
#!/usr/bin/sed -f

s/somename at domain.edu/lbauer@domain,edu/g
 
Old 04-06-2005, 08:10 AM   #4
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
it worked for me. usually when i write a sed script i dont use the shebang (#!). i just run it with
Code:
command_with_output | sed -f sed_script
but i got your simple substitution script to work for me, although my interpreter was not located at /usr/bin/sed, it was /bin/sed. it looked like
Code:
#! /bin/sed -f
s/search/replace/g
i just had to change the permissions to executable so i could use it. then i could pipe some output to it.
Code:
>ls -1
search
search.txt
search_this_file.txt

>ls | ./sed_script
replace
replace.txt
replace_this_file.txt
i guess you should check to make sure you've made the script executable, and that the shebang is right.
Code:
which sed
will tell you were the sed executable is located.
 
Old 04-06-2005, 09:19 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,283

Rep: Reputation: 172Reputation: 172
it's not a shebang!
it's a 'hash-ping'
 
Old 04-06-2005, 12:31 PM   #6
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
you say tomato, i say tomato
http://searchenterpriselinux.techtar...213750,00.html
take a look see.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command rharris72 Programming 6 11-20-2005 08:26 PM
sed command pazvant Linux - Software 2 05-09-2004 12:58 PM
sed command linuxdev Linux - Newbie 9 02-24-2004 04:50 PM
sed Command linuxdev Linux - Newbie 3 02-09-2004 11:27 AM
sed command kwigibo Linux - General 3 04-21-2002 04:11 PM


All times are GMT -5. The time now is 01:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration