Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Running Sed on a file.

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 05-19-2007
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 20 April 2015, 4:34 PM EDT
Location: Foxborough, MA
Posts: 7,805
Thanks: 172
Thanked 647 Times in 605 Posts

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

Sponsored Links
    #3  
Old Unix and Linux 05-21-2007
cfajohnson's Unix or Linux Image
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 5 April 2015, 4:53 PM EDT
Location: Toronto, Canada
Posts: 2,882
Thanks: 0
Thanked 117 Times in 106 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 07:39 AM.