![]() |
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 |
| Need Help with the argument passing Through Command line | asirohi | Shell Programming and Scripting | 5 | 09-04-2009 02:37 AM |
| Command Line Argument | dsudipta | High Level Programming | 2 | 07-09-2009 05:19 AM |
| assign a command line argument and a unix command to awk variables | sweta_doshi | Shell Programming and Scripting | 0 | 08-08-2008 06:54 AM |
| How to get the value in last command line argument??? | amit_oddey21 | Shell Programming and Scripting | 4 | 05-28-2008 07:40 AM |
| passing a command line argument | rudoraj | Shell Programming and Scripting | 8 | 06-13-2007 11:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
finding * in command line argument
I have to write a script to determine whether given command line argument ($1) contains "*" symbol or not, if $1 does not contains "*" symbol add it to $1, otherwise show message "Symbol is not required". For e.g. If we called this script q5 then after giving ,
$ q5 /bin Here $1 is /bin, it should check whether "*" symbol is present or not if not it should print Required i.e. /bin/*, and if symbol present then Symbol is not required must be printed. Test your script as $ q5 /bin $ q5 /bin/* |
|
||||
|
print /* not just *
i tries ur code ..
echo -n "$1" echo "$1" | grep -q '*' || echo '/*' its prints : for sh file.sh /bin --> /bin/* for sh file.sh /bin/* --> /bin/alsacard/* so can you plzz see that and tell me the reason for that , also suggest something else.. |
|
||||
|
As pludi told you, you should learn about the shell before you start writing shell-scripts.
Just try "echo /bin/*", you'll see where the alsacard comes from. Your script will only see the * if no file corresponds to the pattern given on the command line. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|