LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-02-2005, 05:16 PM   #1
King of Men
LQ Newbie
 
Registered: Sep 2005
Distribution: RedHat
Posts: 10

Rep: Reputation: 0
Variable substitution (stupid noob) question in tcsh


I have a bunch of files whose names are of the format runXon, where X is a number between 1 and 4. I would like to write a script that refers to one of these sets at a time, so that I can set a variable RunNumber and do this :

set allfiles = `ls run$RunNumberon`

However, the shell very reasonably complains that RunNumberon is not defined. How can I tell it that the variable name ends before 'on'? I'm sure this is pretty trivial, but I can't find it in my manual.
 
Old 12-02-2005, 05:40 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
i=one
j=run${i}on
 
Old 12-02-2005, 05:44 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
You would have to include a sed or awk expression to parse the filename, looking for the number. If both methods, you would probably have to use characterlists [1..4] to select filenames with a number in that range.

If you don't have them, download Effective Awk Progamming and Awk Users Manual. They include examples of commands to do a great many things. You could probably work it out from that.
 
Old 12-02-2005, 06:26 PM   #4
King of Men
LQ Newbie
 
Registered: Sep 2005
Distribution: RedHat
Posts: 10

Original Poster
Rep: Reputation: 0
Thank you Paul, I knew it had to be something simple.
 
Old 12-04-2005, 09:12 AM   #5
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
Originally Posted by bigrigdriver
You would have to include a sed or awk expression to parse the filename, looking for the number. If both methods, you would probably have to use characterlists [1..4] to select filenames with a number in that range.
Blimey, your scripts must be awesomely complicated.
 
  


Reply



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
the noob is back with another stupid linux question texasnoob Linux - Software 15 05-28-2007 09:06 AM
shell question variable substitution dpressm Programming 9 11-18-2004 07:00 AM
Stupid Noob Question #47 purplemooseman Slackware 2 08-14-2004 01:11 AM
stupid noob driver question wilcox69 Linux - Newbie 2 05-27-2004 11:54 AM
nohup tcsh (environmental variable) podollb Linux - Software 0 05-17-2004 05:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:13 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
Open Source Consulting | Domain Registration