Running Sed on a file. | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Running Sed on a file.

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-19-2007
Paulw0t Paulw0t is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 19 May 2007, 10:41 AM EDT
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Running Sed on a file.

I'm taking in an arguement thats sorted in $file.

The $file contains a file name like file1.txt or something all files are in the same directory as the script..

Can I run sed on the file ? I was thinking of using something like

more file.txt | sed "s/http//"

Something like that is there a way to output the contents of the file and pipe it into sed ?

Thanks.
Sponsored Links
    #2  
Old 05-19-2007
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 22 October 2014, 6:31 PM EDT
Location: Foxborough, MA
Posts: 7,667
Thanks: 152
Thanked 586 Times in 551 Posts

Code:
sed 's/http//' "${file}"

Sponsored Links
    #3  
Old 05-21-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 31 August 2014, 7:32 PM EDT
Location: Toronto, Canada
Posts: 2,877
Thanks: 0
Thanked 110 Times in 102 Posts
Quote:
Originally Posted by Paulw0t
I'm taking in an arguement thats sorted in $file.

The $file contains a file name like file1.txt or something all files are in the same directory as the script..

Can I run sed on the file ? I was thinking of using something like

more file.txt | sed "s/http//"

Something like that is there a way to output the contents of the file and pipe it into sed ?

You don't need more. Just append the names of one or more files after the command:


Code:
sed "s/http//" file.txt file2.txt file3.txt

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
.Profile file not running sol_user Shell Programming and Scripting 1 11-30-2011 04:28 AM
how to make my own file as a running log file in bash blrguest Shell Programming and Scripting 4 04-01-2011 10:15 AM
Running bin file from a module Chrisdot Programming 28 03-20-2011 07:41 PM
running sh file from windows mogabr Shell Programming and Scripting 0 11-10-2008 11:32 AM
Running cmds from a file oxoxo UNIX for Dummies Questions & Answers 2 11-10-2008 02:16 AM



All times are GMT -4. The time now is 09:04 AM.