Linux
linux command - basename
도경다경
2023. 5. 17. 14:10
반응형
basename 명령어는 특이하게 파일의 경로와 파일 확장자명(ex. .log .tar 등)을 없애준다.
# basename /var/log/hist.out .out
이렇게 실행하면 hist 를 출력해준다.
문자열 편집 시 매우 유용한 명령어.
NAME top
basename - strip directory and suffix from filenames
SYNOPSIS top
basename NAME [SUFFIX]
basename OPTION... NAME...
DESCRIPTION top
Print NAME with any leading directory components removed. If
specified, also remove a trailing SUFFIX.
Mandatory arguments to long options are mandatory for short
options too.
-a, --multiple
support multiple arguments and treat each as a NAME
-s, --suffix=SUFFIX
remove a trailing SUFFIX; implies -a
-z, --zero
end each output line with NUL, not newline
--help display this help and exit
--version
output version information and exit
EXAMPLES top
basename /usr/bin/sort
-> "sort"
basename include/stdio.h .h
-> "stdio"
basename -s .h include/stdio.h
-> "stdio"
basename -a any/str1 any/str2
-> "str1" followed by "str2"
반응형