LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 12-03-2009, 05:14 PM   #1
ufmale
Member
 
Registered: Feb 2007
Posts: 386

Rep: Reputation: 30
replacing text from shell script


i am trying to replace a word in a textfile using shell script.
My old batch script calling "sed" works perfectly on Windows.
However, it does not work when I put the sed code in my new shell script running on Redat.

Here is what I had in my batch script. (%1 = first argument)
sed -n "/joe/%1/" oldfile.txt 1> newfile.txt

Can someone suggest how to change it?

Last edited by ufmale; 12-03-2009 at 07:12 PM.
 
Old 12-03-2009, 05:21 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
$1 instead of %1 for starters
 
Old 12-03-2009, 06:27 PM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
[QUOTE]My old batch script calling "sed" works perfectly on Windows.[/QUOTE]

HUH.

End
 
Old 12-04-2009, 09:10 AM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
The long and short is, you can't expect a batch script to work in *nix/*bsd. It's a windows only product, however there is a richer scripting language to work with.

http://www.hypexr.org/bash_tutorial.php
http://linux.about.com/od/bgb_guide/..._Beginners.htm
 
  


Reply



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
How to compare a text value in a shell script and proceed accordingly hemantsankhla Linux - Newbie 8 09-18-2009 12:42 AM
Need a script to search and replace text in file using shell script unixlearner Programming 14 06-21-2007 10:37 PM
Text shell script maxcell Programming 11 03-29-2007 01:31 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM
Replacing a particular position in a file thru shell script in Linux sgracelin Programming 7 06-22-2005 07:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:47 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration