using a vaiable parameters and values to find and tar


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using a vaiable parameters and values to find and tar
# 1  
Old 05-02-2008
using a vaiable parameters and values to find and tar

This one took HOURS and HOURS of my life. Hopefully this post will save someone the same grief.

I am using "-regex" with "find" via a variable. If I echo the command that is constructed, it looks OK. When I paste the echoed text it to the command line it runs fine. But inside the script it generates an error. This led me to the work around which was to pipe the echoed text to bash.

here is the snippet from the script that matters (using GNU bash, version 3.2.33(1)-release (x86_64-redhat-linux-gnu) - Fedora 8):

echo find "$FOLDER" -type f $EXCLUDE
find "$FOLDER" -type f $EXCLUDE
echo find "$FOLDER" -type f $EXCLUDE | bash

here is the output from above 3 lines:

find etc -type f -not \( -regex '^etc/X11/.*' -o -regex '^etc/fonts/.*' \)
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
etc/bla
etc/foo

My question is why does the command not work in the script when it works fine on the command line or when piped to bash?
# 2  
Old 05-02-2008
Precede the name of the directory with a slash:
Code:
/etc

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Extract values based on parameters passing in arguments

Based on arguments passing in command prompt values should fetch and store in new file. Sample:- sh test.sh 10 30 35 45 cat test.sh .. cut -c $1-$2,$3-$4 file_name >> file_new ... ... Above sample passing 4 arguments.. but it may differ (sh test.sh 10 30 35 45 70 75 ) based on... (1 Reply)
Discussion started by: Jairaj
1 Replies

2. UNIX for Dummies Questions & Answers

Default values for positional parameters - dummy question I think

Hi, Sorry for a dummy question I believe. I am just wanting to know how do I assign a default $1 argument if one is not provided. At the moment, I am doing something like below: arg1="${1:-foo}"And then I check $arg1 in case/esac. I am just wondering if there is a way for me to simply do... (3 Replies)
Discussion started by: newbie_01
3 Replies

3. Shell Programming and Scripting

tar cmd how many arguments into parameters of filenames

Hi I would like to use tar cmd in my script. I have a variable with filenames, e.g. 1000 records and I would like to paste its values into tar cmd. For this example I used three elements variable strings. strings="file1.txt file2.txt file3.txt" `tar cf file1.tar $strings` Whether... (1 Reply)
Discussion started by: presul
1 Replies

4. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

5. Solaris

list tunable parameters and its values (Solaris 8)

Does anyone knows how to list tunable kernel parameters on a Solaris 8 system? A linux sysctl -a equivalent will do the job ... (2 Replies)
Discussion started by: danielsf
2 Replies

6. Shell Programming and Scripting

Resetting the Positional parameters values

Hi, Can any one provide the Unix command to reset the positional parameters? Please see the below example where i have to pass 2 parameters to Shell1.sh. Step1) . ./Shell1.sh 2 3 successfully executed, Then i executed(next step only) the same shell script again,this time no... (4 Replies)
Discussion started by: nmk
4 Replies

7. UNIX for Dummies Questions & Answers

Script to update values for the parameters

Hello, I am writing script to substitute values for a parameter in the file but I am getting error. for v1 in grep "pProjectName=" global.cfg do sed -e "/s/$v1/pProjectName=Test/ global.cfg done Please correct me if I am wrong, thanks in advance (1 Reply)
Discussion started by: gmahesh2k
1 Replies

8. Programming

Passing Parameters and getting values back from a c program to Shell script

I am having a shell script which has to be called from a C program. I have to pass two parameters to this script. HOw can I do that? eg: int main() { char st1; char str2; // call a shell script call_sh(str1,str2) where call_sh is the name of the shell script. then i need to get the return... (5 Replies)
Discussion started by: Rajeshsu
5 Replies

9. UNIX for Advanced & Expert Users

tar parameters

Hi, I'm not a very experienced in unix and I need some help. I'm trying to figure out what tar parameters to use to store a directory structure and the files within this directory structure. I also need to know how to extract this tar file from one unix machine to another unix machine. If... (4 Replies)
Discussion started by: kmar
4 Replies
Login or Register to Ask a Question