BASENAME(1) General Commands Manual BASENAME(1)NAME
basename - strip filename affixes
SYNOPSIS
basename string [ suffix ]
DESCRIPTION
Basename deletes any prefix ending in `/' and the suffix, if present in string, from string, and prints the result on the standard output.
It is normally used inside substitution marks ` ` in shell procedures.
This shell procedure invoked with the argument /usr/src/cmd/cat.c compiles the named file and moves the output to cat in the current direc-
tory:
cc $1
mv a.out `basename $1 .c`
SEE ALSO sh(1)BASENAME(1)
Check Out this Related Man Page
basename(1B) SunOS/BSD Compatibility Package Commands basename(1B)NAME
basename - display portions of pathnames
SYNOPSIS
/usr/ucb/basename string [suffix]
DESCRIPTION
The basename utility deletes any prefix ending in `/' and the suffix, if present in string. It directs the result to the standard output,
and is normally used inside substitution marks (` `) within shell procedures. The suffix is a string with no special significance attached
to any of the characters it contains.
EXAMPLES
Example 1 Using the basename command.
This shell procedure invoked with the argument /usr/src/bin/cat.c compiles the named file and moves the output to cat in the current direc-
tory:
example% cc $1
example% mv a.out `basename $1 .c`
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscpu |
+-----------------------------+-----------------------------+
SEE ALSO sh(1), attributes(5)SunOS 5.11 28 Mar 1995 basename(1B)
Does anyone now how to customize an xterm window in solaris to dynamically 'pwd' in the banner. I know how to launch with xterm -n 'cwd' but it does not change when I change dir's. (4 Replies)
I've got one I haven't been able to figure out.
1. A shell script exists- /junk/junk1/junk2/junk3.sh
2. From within the above named shell script, I want to know the full path of the above named shell script. Even if I execute the shell script from a directory other than the one it resides in,... (5 Replies)
hello,
How to search a Word in a shell file and if that exists echo that the word exists and stop that operation and if that doesn't exists then echo word not found.
Thanks in advance.
Bye (4 Replies)
ever since i started playing with unix at work i have found all kinds of helpful tools that my companie has added into our /usr/bin/
this is the one that helped the most
""""""ldr"""""""
#!/bin/sh
#
# @(#) %filespec: ldr-2 % %date_modified: Wed Sep 6 09:54:07 2000 %
#
# ... (4 Replies)
does anyone know how to combine 2 lines? this is what im playing around with.
(filename: online, user name: prml0001, real name: primal)
#!/bin/sh
who | grep $1 > /dev/null
if
then
grep $1 /etc/passwd | cut -f 5, -d :
echo is logged on
exit 0
else
grep $1... (13 Replies)
I have a script that sorta works the way I want but I would rather
just get the base name and line number from the grep output.
My current script is this one liner:
grep -n "$1" $SCCSPATH/*/s.*.k | cut -c1-80
which if I was searching for 121197 I would get something like this:
... (18 Replies)
Hi there,
Is there any way to obtain a real path from a weird path. For example :
/foo/../bar/ -> /bar/
/foo/. -> /foo/
Thanks in advance
Santiago (5 Replies)
Hi guys if i do
a=`basename -e -s /home/j/john/*`
du -k -h $a | sort -nr | head -10
why when i run the script does it work but also say usage basename string
any ideas thanks (9 Replies)
hi if we have to use basename how can we do this in awk?
did the below but is not working..
psg -t "?"| awk '{
command=($5 ~ /^/)? $9:$8
# cmd_name=`basename $command` (gives error)
system("basename $command >>... (10 Replies)
Hi
Can somebody please help me know how do i match the basename using a regular expression using posix standard in shell script
suppose i want to match
/u01/Sybase/data/master.dbf the result should be master.dbf as i want to match everything after the last /
regards (8 Replies)
Hi all,
/home/test/test 123.txt
i want exact file name like "test 123.txt"
basename shows wrong output
how can i cut text from 1st charaster to last "/".....? (5 Replies)
im trying to extract the basename of a process running on a host
processx is running at host1 as /applications/myapps/bin/processx
i wanted to check if its running, then extract the basename only using:
$ ssh host1 "ps aux | grep -v 'grep' | grep 'processx'" | awk '{ print basename $11}'
... (10 Replies)
Hi ! all
I have need of accessing multiple files of different type same base name, and I want to compare base name if matching then I want to send those 2 files of different type to some program, for further processing
my files are like this
file_1.txt
file_2.txt
file_3.txt
file_4.txt... (6 Replies)
hi all,
trying to get this to work but im struggling abit and wondered if you can help me out
basically i have created a variable
base='basename $dir'
echo "please specify full path to directory you want to be made into a tar"
read -e dir
tar -cf... (7 Replies)