Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

basename(1) [redhat man page]

BASENAME(1)								FSF							       BASENAME(1)

NAME
basename - strip directory and suffix from filenames SYNOPSIS
basename NAME [SUFFIX] basename OPTION DESCRIPTION
Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX. --help display this help and exit --version output version information and exit AUTHOR
Written by FIXME unknown. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for basename is maintained as a Texinfo manual. If the info and basename programs are properly installed at your site, the command info basename should give you access to the complete manual. GNU coreutils 4.5.3 February 2003 BASENAME(1)

Check Out this Related Man Page

BASENAME(1)							   User Commands						       BASENAME(1)

NAME
basename - strip directory and suffix from filenames SYNOPSIS
basename NAME [SUFFIX] basename OPTION DESCRIPTION
Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX. --help display this help and exit --version output version information and exit EXAMPLES
basename /usr/bin/sort Output "sort". basename include/stdio.h .h Output "stdio". AUTHOR
Written by David MacKenzie. REPORTING BUGS
Report basename bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
dirname(1), readlink(1) The full documentation for basename is maintained as a Texinfo manual. If the info and basename programs are properly installed at your site, the command info coreutils 'basename invocation' should give you access to the complete manual. GNU coreutils 7.1 July 2010 BASENAME(1)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

customizing xterm windows

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)
Discussion started by: toddy44
4 Replies

2. UNIX for Dummies Questions & Answers

Original Path

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)
Discussion started by: therealtiger
5 Replies

3. UNIX for Advanced & Expert Users

search and Replace

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)
Discussion started by: mukeshannamalai
4 Replies

4. UNIX for Dummies Questions & Answers

this helps me out big time

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)
Discussion started by: jerzey4life
4 Replies

5. UNIX for Dummies Questions & Answers

combine 2 lines (command & echo)

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)
Discussion started by: primal
13 Replies

6. Shell Programming and Scripting

need grep to output basename and line#

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)
Discussion started by: zoo591
18 Replies

7. Shell Programming and Scripting

reverse of basename

Hi, Can someone let me know how to find the reverse of the basename i.e i have /apps/tiv/pmon/xxxx.dat and I want /apps/tiv/pmon/ Thanks (7 Replies)
Discussion started by: braindrain
7 Replies

8. Shell Programming and Scripting

geting the real path

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)
Discussion started by: chebarbudo
5 Replies

9. Shell Programming and Scripting

basename problem

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)
Discussion started by: musicmancanora4
9 Replies

10. Shell Programming and Scripting

getting basename inside awk script

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)
Discussion started by: Anteus
10 Replies

11. Shell Programming and Scripting

regex to match basename

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)
Discussion started by: xiamin
8 Replies

12. Shell Programming and Scripting

basename + file with space

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)
Discussion started by: jagnikam
5 Replies

13. UNIX for Dummies Questions & Answers

awk and basename

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)
Discussion started by: kaboink
10 Replies

14. Shell Programming and Scripting

Reading files of different type and same basename

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)
Discussion started by: Akshay Hegde
6 Replies

15. Programming

Basename for directory variable

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)
Discussion started by: robertkwild
7 Replies