The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problems with cut scorpio Shell Programming and Scripting 6 04-28-2008 08:49 AM
NIS+ problems wjones UNIX for Advanced & Expert Users 0 04-09-2008 05:30 AM
RCP problems Daishi UNIX for Dummies Questions & Answers 0 09-10-2007 05:20 AM
More SSH Problems..... Neo News, Links, Events and Announcements 1 12-19-2002 02:07 PM
'make' problems (compliation problems?) xyyz UNIX for Advanced & Expert Users 5 11-05-2001 10:47 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-21-2009
lassimanji lassimanji is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 58
problems using sed

i have a file acc.sh which has about 10 lines and then i have defined $var which has a line number in it (say 5). i want to extarct from line 5 to the end of the file and put the output into another file. I have used
sed -n $var,'$p' acc.sh | tee abc.sh
but at times it does'nt work and gives an error like
sed: -e expression #1, char 1: unknown command: `,'
can you help me with this.
thanks
  #2 (permalink)  
Old 04-21-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Code:
 sed "$var,\$ p" acc.sh | tee abc.sh
escape the second $ character add a space before the p character.
  #3 (permalink)  
Old 04-21-2009
lassimanji lassimanji is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 58
doen't work.it copies the whole file
  #4 (permalink)  
Old 04-21-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
What OS and sed are you using? Works for me on HPUX 11.23 sed under /bin/ksh
  #5 (permalink)  
Old 04-21-2009
lassimanji lassimanji is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 58
if abc.sh is
192.168.1.41

then the output that i get is v5c01

my code is
sed 's/192.168.1.4/v5c0/g
s/192.168.1.41/acc1/g' abc.sh 2>&1 | tee abc.sh

i want to find 192.168.1.4 and replace it with v5c0
and find 192.168.1.41 and replace it with acc1

and i want to do it using sed
  #6 (permalink)  
Old 04-21-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
use > not |
Code:
sed "$var,\$ p" acc.sh > abc.sh
I though abc.sh was a shell script executing your output, my bad.
  #7 (permalink)  
Old 04-21-2009
lassimanji lassimanji is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 58
it works now thanks ...can you please help me with the second problem as well
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0