![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| alias two words command line | harlock59 | Shell Programming and Scripting | 3 | 07-14-2009 08:32 AM |
| how to extend words on a command line ? | venhart | UNIX for Dummies Questions & Answers | 6 | 07-16-2008 11:22 AM |
| overlapping words on command line | gaurav123 | UNIX for Dummies Questions & Answers | 4 | 07-01-2008 12:21 PM |
| displaying mutliple fields on command line | Trellot | UNIX for Dummies Questions & Answers | 3 | 11-02-2007 07:37 AM |
| Identify duplicate words in a line using command | srinivasan_85 | UNIX for Dummies Questions & Answers | 8 | 05-01-2007 02:29 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to set mutliple words variable from command line
I'm writing a script (C shell) to search for a pattern in file. For example scriptname pattern file1 file2 filenN I use for loop to loop through arguments argv, and it does the job if all arguments are supplied. However if only one argument is supplied (in that case pattern ) it should ask to input file name or names, and then check for pattern. How I can set variable to include multiple words input from command line so I can use it in loop. Or even better is it possible to assign command line input to argv, so I don’t have to use the same loop twice only because it is different variable name (one to loop through argv if more than on argument, and second to loop through filenames variable if only one argument supplied). Below is the part of my script which is causing problem: Code:
set pattern = $1
if ($#argv == 1) then
echo "Enter name of files"
set filenames = $< #how I can set it to accept more than word?
endif
Any help will much appreciated. Last edited by Neo; 4 Weeks Ago at 12:59 PM.. Reason: Added code tags. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|