#! Lum7671's Weblog
* ^______________^ *
#! Lum7671's Weblog
zsh tips

zsh 에서 기억하고 싶은 것들…

expr

% expr 10 \* 3
30
% expr length 1234567
7
# expr substr [string] [pos] [length]
% expr substr 1234567 3 2
34
# expr index [string] [chars]
% expr index 1234567 34
3

noglob

파일 이름 치환 기능을 비활성화한다.
% echo *
file1 file2 file3 file4
% ls *
file1 file2 file3 file4
% *
zsh: permission denied: file1
$ set -o noglob
$ echo *
*
$ ls *
ls: cannot access '*': No such file or directory
$ *
zsh: command not found: file1

참고: “set -o noglob” in bash shell script - Stack Overflow

*’ 추가 사항

% *
zsh: command not found: a.sh
% ls
a.sh*  b.sh*
% cat *
#!/usr/bin/env sh
echo "a"
#!/usr/bin/env sh
echo "b"
% export PATH=.:$PATH
% *
a

ls

permission 으로 찾기

# file ownership/permissions
ls -ld *.*(u:apache:)         # find all files that don’t have the write permission to group in current directory and all subdirectories
ls **/*(.:g-w:)
ls *(.f644)                   # files with permissions 644
ls *(.g:root:)                # files belonging to group root
ls *(.u:apache:)              # files belonging to user apache
ls -l *(.rwg:nobody:u:root:)  # user has read/write permissions