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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk print the next line on the current line ajp7701 Shell Programming and Scripting 5 05-25-2009 12:17 PM
print line whatever line i want in a file... there any way kittusri9 Shell Programming and Scripting 1 05-15-2008 12:37 PM
How to print a value in the variable using awk ? jisha Shell Programming and Scripting 1 01-14-2008 07:45 AM
Print file line by line handak9 Shell Programming and Scripting 2 10-20-2005 08:44 AM
print variable in awk kazanoova2 Shell Programming and Scripting 8 05-17-2004 06:30 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-24-2007
atchleykl atchleykl is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 3
use variable for sed print line

I'm using the sed command to pull a line from a file and place it into another file:

sed -n '1p' students >tmp

this pulls the first line, I want to change the 1 to a variable which will be a counter to go through the rest of the lines but can't get it. I've tried:

sed -n '$cp students >tmp
sed -n $cp students >tmp

neither work. Any ideas? Thanks!
  #2 (permalink)  
Old 04-24-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
double quotes, and {} around the variable ie "${c}p"
  #3 (permalink)  
Old 04-24-2007
atchleykl atchleykl is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 3
PERFECT!! Thanks so much!!
  #4 (permalink)  
Old 02-23-2009
dennis89 dennis89 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 2
Smile

Thanks, I had the same situation and same problem .
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 09:33 AM.


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