![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Storing commands in $variables. | Paulw0t | Shell Programming and Scripting | 7 | 08-08-2008 05:42 PM |
| Using variables in sed commands | hcclnoodles | Shell Programming and Scripting | 2 | 01-02-2007 08:56 AM |
| Passing variables/arguments/parameters to commands | Perderabo | Answers to Frequently Asked Questions | 0 | 06-13-2004 07:37 PM |
| Subtracting Variables which are commands | Astudent | UNIX for Dummies Questions & Answers | 2 | 03-30-2001 09:55 AM |
| Subing Variables with commands. | Astudent | UNIX for Dummies Questions & Answers | 1 | 02-26-2001 05:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Referencing variables in commands
The script I am writing must be able to run several commands (tar, gzip etc) on filenames that are supplied by variables. I am unsure as to what syntax is required/ideal when referencing variables in filenames. The following is a sample command that I would like the script to execute:
Code:
tar cvf bk{fileName}.${DATEyear}${DATEmonth}.tar {fileName}.${DATEyear}${DATEmonth}* >> /ebccsBackupReport.txt
Also, is there a way to verify where one or more files bearing a variation on a filename exist within the directory? For example, all files under filename.*? I have been using Code:
if [ -f filename.* ] I'm using Ksh 88 under Solaris 8. Thanks for all the help. |
|
|||||
|
Quote:
Code:
root_box:/tmp # touch filename.1 filen.1 filename.3 file.3 file4 root_box:/tmp # ls file* file.3 file4 filen.1 filename.1 filename.3 root_box:/tmp # if [ -f filename.* ] > then > ls filename.* > else > ls > fi filename.1 filename.3 root_box:/tmp # rm filename.1 filename.3 root_box:/tmp # ls file.3 filen.1 orbit-root speckeysd.lock file4 mpHyay4c plugtmp root_box:/tmp # ls file* file.3 file4 filen.1 root_box:/tmp # if [ -f filename.* ] > then > ls filename.* > else > ls > fi file.3 filen.1 orbit-root speckeysd.lock file4 mpHyay4c plugtmp root_box:/tmp # |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|