![]() |
|
|
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 |
| help needed with creating challenging bash script with creating directories | I-1 | Shell Programming and Scripting | 7 | 04-29-2009 06:33 AM |
| how to make your bash script run on a machine with csh and bash | npatwardhan | Shell Programming and Scripting | 3 | 11-19-2008 04:17 AM |
| (w)get web server's directories + bash script | reminiscent | Shell Programming and Scripting | 2 | 08-20-2008 01:21 PM |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 01:25 PM |
| Bash Script to display directories in Path? | debut | Shell Programming and Scripting | 1 | 11-09-2005 05:06 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Bash script: issue changing directories in script
I am working on a script that checks two arguments at the command line. The first argument is a search pattern, the second can be a file or a directory, if it is a file a second script is called that checks it for the search pattern. If the second argument is a directory, it checks for the search pattern in all files in the that directory.
The script works ok if the second argument is a sub-directory of the working directory of the script. The issue occurs when the script needs to change directories. I don't think it likes the "/" if I specify a directory, but i'm stuck as far figuring out what to do next. Here is the snippet of code I am having the trouble with: Code:
elif [ -d $2 ] #test the command line argument for a directory
then
#change directories to the the second command line argument
cd $2
filename=`ls -l | cut -c59-78`
for entry in $filename
do
# Verify that the name read in the directory is a file
if [ -f $filename ]
then
# Search the files for the pattern specified by $1, then call search.sh
./search.sh $1 $listing
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|