The UNIX and Linux Forums  

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
How to get the value in last command line argument??? amit_oddey21 Shell Programming and Scripting 4 05-28-2008 08:40 AM
passing a command line argument rudoraj Shell Programming and Scripting 8 06-14-2007 12:06 AM
array as command line argument !!!! spandu UNIX for Dummies Questions & Answers 2 02-21-2006 01:33 PM
repeating previous argument on command line? hadarot UNIX for Dummies Questions & Answers 6 08-01-2005 03:41 AM
command line argument parsing rmjoe UNIX for Dummies Questions & Answers 1 07-28-2005 04:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-25-2004
rkumar28 rkumar28 is offline
Registered User
  
 

Join Date: Apr 2004
Posts: 34
Passing the command line argument in a variable

Hi,
I am new to unix. Is their a way to pass the output of the line below to a variable var1.
ls -1t | head -1.

I am trying something like var1=ls -1t | head -1, but I get error.

Situation is: I get file everyday through FTP in my unix box. I have to write a script that picks up first latest file that comes in and pass the content of that file to another file called the load.txt. The FTP filename changes depending on the source.

I tried something like:

var1=ls -1t | head -1
cat $var1>load.txt
I error out on the first line of my script.

Also I tried something like var1=ls -1t | head -1 | cat >load.txt. But I am not getting the desired result.

I will really appreciate any help in this regards.
  #2 (permalink)  
Old 05-26-2004
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,807

Code:
var1=`ls -1t | head -1`

Those are backticks...
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 02:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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