LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 08-22-2007, 10:10 AM   #1
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Rep: Reputation: 15
tcsh set/read variable command?


Hi.

Writing a shell script in tcsh. (It has to be tcsh as it calls routines that only run under tcsh). I usually use bash.

As an example, in bash you can assign the output from a command to a variable:

Code:
lines=$(wc -l somefile | awk '{print $1}')
to simply assign number of lines in a file to the variable lines...

Can anyone help me with the equivalent tcsh syntax? It's driving me mad! None of what follow work...

Code:
lines=$(wc -l somefile | awk '{print $1}')

@ lines = $(wc -l somefile | awk '{print $1}')

set lines = $(wc -l somefile | awk '{print $1}')

wc -l somefile | awk '{print $1}'
@ lines = $<

wc -l somefile | awk '{print $1}'
set lines = $<

 @ lines < (wc -l somefile | awk '{print $1}')

wc -l somefile | awk '{print $1}' | @ lines = $<
 
Old 08-22-2007, 10:22 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Back quotes should work in tcsh:
Code:
set lines=`wc -l somefile | awk '{print $1}'`
 
Old 08-22-2007, 10:26 AM   #3
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Original Poster
Rep: Reputation: 15
yep that's worked!

thank you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tcsh read command? johnpaulodonnell Linux - Newbie 2 07-13-2007 08:53 AM
How to set PATH variable for command tracert? princegbenga Linux - Software 2 06-14-2007 08:48 AM
set the ouput of a command to a variable true_atlantis Linux - Newbie 2 03-23-2006 04:30 PM
Variable substitution (stupid noob) question in tcsh King of Men Linux - Newbie 4 12-04-2005 10:12 AM
nohup tcsh (environmental variable) podollb Linux - Software 0 05-17-2004 06:44 PM


All times are GMT -5. The time now is 10:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration