Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable to tail -n command 1

Status
Not open for further replies.

LadyDragon

Programmer
Jan 14, 2004
24
0
0
US
Hi! I was hoping someone could help me with this. I'm working in Korn shell and am trying to pass a variable to a tail command and am having problems doing this.

Code:
tail -"$var" > out.txt

The quoted part is where I'm having problems. Ideas would be appreciated! Thanks!

Juls
 
Try...
Code:
eval tail -${var} \> out.txt
Hope this helps.
 
Hmmm, actually this should work too...
Code:
tail -${var} > out.txt
But this isn't specifying what you're tailing. You need to either pipe something to it, or specify a file name to tail...
Code:
tail -${var} file.txt > out.txt
# or
some_command | tail -${var} > out.txt
Hope this helps.
 
Thanks Sambones. The lack of input file was a cut'n'paste error on my part. Your suggestion worked!

Thanks!
Juls
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top