Processing Multiple Arguments in Command Line Options
Hi All,
I am new to scripting. Could you please assist me .
Here is my requirement. I have written a script that has 2 option flags defined.
-l) calls some function with the arguments passed in front of -l
-r) calls second function with the arguments passed in front of -r
*) calls the third function with arguments specified.
For this I have written-
While executing-
Scenario 1- ./test -l file1 file2 file3
I am only able to capture the argument file1 with -l . The arguments file2 and file3 are passed to the *) option.
Could you please let me know how to pass all the arguments to the function called from -l) option.
Thanks a lot
Last edited by vbe; 07-05-2013 at 08:58 AM..
Reason: code tags
Since i need to call a function check_path if no option (-l etc) is passed, it is becoming increasingly difficult for me to capture multiple arguments passed to an option. .
@zaxxon - It worked partially. I was able to list the arguments passed to -l option.
The only problem was that, these arguments were also passed to the *) option.
Hi,
I'd like find multiple file options to fetch different types of files.
find /path...// -type f -name "*.log" -o -name "*.req" -o -name "*.txt" -mtime +5 -exec ls -l {} \;
Where as in the above command only the last .txt files its retriving but not .log and .req files can body help... (1 Reply)
Hi all,
What am trying do is search for a directory that is owned by cm that only exists in a path that has a particular directory
ex: what I'm using now is
find . -user cm -name '*.rel' -type d -exec ls -dl {} \;
This is giving me stuff like this
./../../foo1/../../*.rel... (2 Replies)
Hi All,
I am having two files (file1 & file2) and a filelist.txt file below.
file1:
$$STRINGVAR1=5
$$STRINGVAR2=10
$$LAST_UPD_DT_TBL1=12/12/2010 12:00:00
$$STRINGVAR3=100
$$LAST_UPD_DT_TBL2=01/01/2010 12:00:00... (8 Replies)
Hi all
I have spent half a day trying to create a shell script which reads a configuration file on a line by line basis.
The idea of the file is that each will contain server information, such as IP address and various port numbers. The line could also be blank (The file is user created). Here... (1 Reply)
I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing
set
you can also use them "on the command line when running a script..." and it lists this in a small table:
set -o option Command Line... (5 Replies)
Hello All,
Is there a way to make exec do a couple of operations on a single input from find?
For example,
find . -type d -exec ls -l "{}" ";"
I would like to give the result of each "ls -l" in the above to a wc. Is that possible?
I want to ls -l | wc -l inside exec. How do I... (1 Reply)
Hi all,
I want to get options from command line by perl.
usage()
options:
-h Show this help message and exit
-t Name of tester
--timeout Set the timeout
-l ... (1 Reply)
suppose the user enters: ./Myfile blah1 blah2 blah3
I want to be able to read that in as: blah1blah2blah3
IN ONE VARIABLE
Obviously I can print it out in one line excluding the white space, but I'm having trouble combining argv, argv, ....., argv together!
This is what I tried, but I... (3 Replies)
my description from another thread...
here's my code:
#!/bin/bash
IFS=$'\n'
function OutputName() {
input=$1
echo $input
input=`echo "$input" | sed -e 's/.//'`
input=`echo "$input".avi`
output_name=$input
}
if ]; then
echo... (5 Replies)