Sponsored Content
Full Discussion: Begining Shell scripter
Top Forums Shell Programming and Scripting Begining Shell scripter Post 302140077 by synak on Wednesday 10th of October 2007 03:39:43 PM
Old 10-10-2007
#!/bin/bash
if [ $# -ne 1 ]
then
echo "usage: `basename $0` <-l|-w>"
exit 1
fi

case "$1" in
-l)
echo lines/filename
wc -l * | sort | grep -v ` basename $0` | grep -v ' total'
;;
-w)
echo words/filename
wc -w * | sort | grep -v ` basename $0` | grep -v ' total'
;;
*)
echo "usage: $0 <-l|-w>"
exit 1
;;
esac
 

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use of #! at the begining ?

All, i have some doubt on #!/bin/bash or #!/bin/ksh at the begining of script. Need to know folowing thing ? -- what would be the problem if i will mention in the first line #!/bin/bash and will use korn shell syntax and the reverse ? -- Can i mention at the... (1 Reply)
Discussion started by: jambesh
1 Replies

2. Shell Programming and Scripting

new scripter

Hello all, new to scripting (and unix!) here. Im trying to write a script for something i have to do for work and for some reason it just isnt working. im using the ksh. Can someone please tell me why $PRODUCT=$1 CONFIG=./etc/$PRODUCT_config.xml print Using $CONFIG prints... (1 Reply)
Discussion started by: Gwoodhouse0
1 Replies
BASENAME(3)								 1							       BASENAME(3)

basename - Returns trailing name component of path

SYNOPSIS
string basename (string $path, [string $suffix]) DESCRIPTION
Given a string containing the path to a file or directory, this function will return the trailing name component. PARAMETERS
o $path - A path. On Windows, both slash ( /) and backslash ( ) are used as directory separator character. In other environments, it is the forward slash ( /). o $suffix - If the name component ends in $suffix this will also be cut off. RETURN VALUES
Returns the base name of the given $path. EXAMPLES
Example #1 basename(3) example <?php echo "1) ".basename("/etc/sudoers.d", ".d").PHP_EOL; echo "2) ".basename("/etc/sudoers.d").PHP_EOL; echo "3) ".basename("/etc/passwd").PHP_EOL; echo "4) ".basename("/etc/").PHP_EOL; echo "5) ".basename(".").PHP_EOL; echo "6) ".basename("/"); ?> The above example will output: 1) sudoers 2) sudoers.d 3) passwd 4) etc 5) . 6) NOTES
Note basename(3) operates naively on the input string, and is not aware of the actual filesystem, or path components such as " ..". Note basename(3) is locale aware, so for it to see the correct basename with multibyte character paths, the matching locale must be set using the setlocale(3) function. SEE ALSO
dirname(3), pathinfo(3). PHP Documentation Group BASENAME(3)
All times are GMT -4. The time now is 02:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy