Strict Argument


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strict Argument
# 1  
Old 11-24-2008
Strict Argument

Im trying to write a bash script that has an if statment that when the user enters ONLY that exact argument, will echo what follows that conditon.

For example:
Code:
for file in $1
do
 
if [ $ == "$1" ]
then
Var1=$(cat hello | egrep "that pattern" | awk '{ print $NF }')
cat $Var1
fi
done

Basically, if i specify anything other then 1 as this cmd files argument, it wont output anything.

But if i do specify 1 it will output the value that Var1 is holding... Another problem tha t i was having is that it will output when any 1 argument is passed. For example if 2 arguments are passed it wont output anything. If no arguments are passed it wont output anything. But it really doesnt matter what 1 argument i specify, it will output as long as 1 argument is givin.

What im trying to figure out from that point is how to write an if statement that looks for an exact match of that 1 argument that the user would specify.
# 2  
Old 11-24-2008
It's not clear what you're trying to achieve.

What is the practical business problem you are solving?
# 3  
Old 11-24-2008
string="anything.txt"

doesnt work because its of a text file extension..why?

i need to use that with an if
# 4  
Old 11-24-2008
I have had enough of this. oxoxo is banned for continually posting homework/classroom problems.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl : Getopts and Strict -How to solve

How do I get past the error when using strict and GetOpts ? #!/usr/bin/perl use strict; use Getopt::Std; # Process the command line options die "Usage: $0 -r <router> -u <username> -p <password> -e <enable password>\n" if (@ARGV < 6); exit if (!getopts('r:u:p:e:')); my... (3 Replies)
Discussion started by: popeye
3 Replies

2. UNIX for Advanced & Expert Users

Ssh disable strict checking

What are the different ways to disable ssh strict checking? I've seen this mentioned a few times but it doesn't seem to be working. $ ssh -o 'StrictHostKeyChecking no' admin@hostnamehttp://docs.oracle.com/cd/E35328_01/E35336/html/vmcli-ssh.html Is there a file somewhere in /etc that I could... (4 Replies)
Discussion started by: cokedude
4 Replies

3. Shell Programming and Scripting

Help! Can't locate strict.pm after Cygwin update

I installed gcc4 today using setup.exe from cygwin. However, I cannot run any of my perl program after that. For example, Run@Run-THINK /home $ perl Process.pl Can't locate strict.pm in @INC (@INC contains: /usr/lib/perl5/5.10/i686-cygwin / usr/lib/perl5/5.10... (0 Replies)
Discussion started by: littledeer
0 Replies

4. UNIX for Advanced & Expert Users

Error:--test: argument expected--Even though i give an argument.

Hi All, I am running the script VBoxManage list vms |sed 's/"//g' | cut -d " " -f1 > har1out.mytxt result=`cat har1out.mytxt | grep $1' echo $result echo $1 { if then echo pass else echo fail fi (2 Replies)
Discussion started by: harsha85
2 Replies

5. Shell Programming and Scripting

Cannot compare argument in if statement in csh/grep command if argument starts with “-“

If ($argv == “-debug”) then Echo “in loop” Endif But this is not working. If I modify this code and remove “-“, then it works. Similarly I am getting problem using grep command also Grep “-debug” Filename Can someone please help me on how to resolve these... (1 Reply)
Discussion started by: sarbjit
1 Replies

6. Shell Programming and Scripting

New PERL guru's help on strict.pm

I opened strict.pm and found some not understandable stuff, please let me know if you have any Idea on the same. 1) Line 23 => $bits |= (what is $= here how it affect the statement) 2) Line 36 => $^H (what is that I haven't found any statement on this in google) 3) Line 41 =>... (3 Replies)
Discussion started by: jatanig
3 Replies

7. Shell Programming and Scripting

get positive number n as argument script must calculate the factorial of its argument

Can someone please help me with this SHELL script? I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1. Here is a start but I have no clue how to... (3 Replies)
Discussion started by: I-1
3 Replies

8. Shell Programming and Scripting

Perl strict

What is the sake of using `use strict;` in perl codes? and how can avoid it?.TnX. (8 Replies)
Discussion started by: Zaxon
8 Replies

9. UNIX for Dummies Questions & Answers

How to find the last argument in a argument line?

How to find the last argument in a argument line? (4 Replies)
Discussion started by: nehagupta2008
4 Replies
Login or Register to Ask a Question