X-Git-Url: http://git.grml.org/?a=blobdiff_plain;ds=inline;f=zsh-lovers.1.txt;h=4512dc3a266a22ab133928b35899101cf7eec63c;hb=900a04e6d3a2ca006cd55d49e03a25ee35952a5c;hp=c682229fa512c5aa95694f5646ba5c0c8b711f6c;hpb=7e727d3b0499f822dd25ec65c65413ea87050e6a;p=zsh-lovers.git
diff --git a/zsh-lovers.1.txt b/zsh-lovers.1.txt
index c682229..4512dc3 100644
--- a/zsh-lovers.1.txt
+++ b/zsh-lovers.1.txt
@@ -37,7 +37,7 @@ parse_options()
o_root=(-r WWW)
o_log=(-d ZWS.log)
- zparseopts -K -- p:=o_port r:=o_root h=o_help
+ zparseopts -K -- p:=o_port r:=o_root l:=o_log h=o_help
if [[ $? != 0 || "$o_help" != "" ]]; then
echo Usage: $(basename "$0") "[-p PORT] [-r DIRECTORY]"
exit 1
@@ -78,6 +78,7 @@ $ grep alias ~/.zsh/* C
----------------------
Some more or less useful global aliases (choose whether they are useful or not
for you on your own):
+
--------------------------------------------------------
alias -g ...='../..'
alias -g ....='../../..'
@@ -150,7 +151,7 @@ zstyle ':completion:*:approximate:*' max-errors 1 numeric
And if you want the number of errors allowed by _approximate to
increase with the length of what you have typed so far:
---------------------------------------------------------------------------------------------------
-zstyle -e ':completion:*:approximate:*' \
+zstyle -e ':completion:*:approximate:*' \
max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
---------------------------------------------------------------------------------------------------
@@ -195,6 +196,13 @@ Hint: A list of valid glob Qualifiers can be found in zshexpn(1).
See ``man 1 zshexpn | less -p'' Qualifiers for details.
-------------------------------------------------------------------------------
+# test if a parameter is numeric
+ $ if [[ $1 == <-> ]] ; then
+ echo numeric
+ else
+ echo non-numeric
+ fi
+
# Show me all the .c files for which there doesn't exist a .o file.
$ c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}'
@@ -215,54 +223,54 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
# Fetch the newest file containing the string 'fgractg*.log' in the
# filename and contains the string 'ORA-' in it
- $ file=(fgractg*.log(Nm0om[1]))
+ $ file=(fgractg*.log(Nm0om[1]))
$ (($#file)) && grep -l ORA- $file
# without Zsh
$ files=$( find . -name . -o -prune -name 'fgractg*>log' -mtime 0 -print )
- > if [ -n "$files" ]; then
- > IFS='
+ > if [ -n "$files" ]; then
+ > IFS='
> '
- > set -f
- > file=$(ls -td $files | head -1)
- > grep -l ORA- "$file"
+ > set -f
+ > file=$(ls -td $files | head -1)
+ > grep -l ORA- "$file"
> fi
# keep specified number of child processes running until entire task finished
$ zsh -c 'sleep 1 & sleep 3 & sleep 2& print -rl -- $jobtexts'
-
+
# Remove zero length and .bak files in a directory
$ rm -i *(.L0) *.bak(.)
# print out files that dont have extensions
$ printf '%s\n' ^?*.*
$ printf '%s\n' ^?*.[^.]*(D)
- $ ls -d -- ^?*.*(D)
+ $ ls -d -- ^?*.*(D)
# Finding files which does not contain a specific string
$ print -rl file* | comm -2 -3 - <(grep -l string file*)'
$ for f (file*(N)) grep -q string $f || print -r $f'
-# Show/Check whether a option is set or not. It works both with $options as
+# Show/Check whether a option is set or not. It works both with $options as
# with $builtins
$ echo $options[correct]
off
$ $options[zle]
on
-
+
# Count the number of directories on the stack
$ print $((${${(z)${(f)"$(dirs -v)"}[-1]}[1]} + 1)) # or
$ dirs -v | awk '{n=$1}END{print n+1}'
# Matching all files which do not have a dot in filename
$ ls *~*.*(.)
-
+
# Show only the ip-address from ``ifconfig device''
# ifconfig from net-tools (Linux)
- $ print ${${$(LC_ALL=C /sbin/ifconfig eth0)[7]}:gs/addr://}
+ $ print ${${$(LC_ALL=C /sbin/ifconfig eth0)[7]}:gs/addr://}
# ifconfig from 4.2BSD {Free,Net,Open}BSD
- $ print ${$(/sbin/ifconfig tun0)[6]}
+ $ print ${$(/sbin/ifconfig tun0)[6]}
-# Ping all the IP addresses in a couple of class C's or all hosts
+# Ping all the IP addresses in a couple of class C's or all hosts
# into /etc/hosts
$ for i in {1..254}; do ping -c 1 192.168.13.$i; done
or
@@ -275,21 +283,21 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
: ping -c 1 $i ;
: echo '============================='
: done
-
+
# load all available modules at startup
$ typeset -U m
$ m=()
$ for md ($module_path) m=($m $md/**/*(*e:'REPLY=${REPLY#$md/}'::r))
$ zmodload -i $m
-# Rename all files within a directory such that their names get a numeral
+# Rename all files within a directory such that their names get a numeral
# prefix in the default sort order.
$ i=1; for j in *; do mv $j $i.$j; ((i++)); done
$ i=1; for f in *; do mv $f $(echo $i | \
awk '{ printf("%03d", $0)}').$f; ((i++)); done
$ integer i=0; for f in *; do mv $f $[i+=1].$f; done
-# Find (and print) all symbolic links without a target within the current
+# Find (and print) all symbolic links without a target within the current
# dirtree.
$ $ file **/*(D@) | fgrep broken
$ for i in **/*(D@); [[ -f $i || -d $i ]] || echo $i
@@ -313,7 +321,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
# Synonymic to ``ps ax | awk '{print $1}'''
$ print -l /proc/*/cwd(:h:t:s/self//)
-# Get the PID of a process (without ``ps'', ``sed'', ``pgrep'', ..
+# Get the PID of a process (without ``ps'', ``sed'', ``pgrep'', ..
# (under Linux)
$ pid2 () {
> local i
@@ -340,14 +348,14 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
$ cd -- $dest_root
$ mkdir -p -- $dirs
# or without zsh
- $ find . -type d -exec env d="$dest_root" \
+ $ find . -type d -exec env d="$dest_root" \
sh -c ' exec mkdir -p -- "$d/$1"' '{}' '{}' \;
# If `foo=23'', then print with 10 digit with leading '0'.
$ foo=23
$ print ${(r:10::0:)foo}
-# find the name of all the files in their home directory that have
+# find the name of all the files in their home directory that have
# more than 20 characters in their file names
print -rl $HOME/${(l:20::?:)~:-}*
@@ -356,8 +364,8 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
$ eval "m=($(cat -- $nameoffile)" # or use
$ m=("${(@Q)${(z)"$(cat -- $nameoffile)"}}") # to restore it
-# get a "ls -l" on all the files in the tree that are younger than a
-# specified age (e.g "ls -l" all the files in the tree that where
+# get a "ls -l" on all the files in the tree that are younger than a
+# specified age (e.g "ls -l" all the files in the tree that where
# modified in the last 2 days)
$ ls -tld **/*(m-2)
# This will give you a listing 1 file perl line (not à la ls -R).
@@ -422,16 +430,16 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
# Convert images (foo.gif => foo.png):
$ for i in **/*.gif; convert $i $i:r.png
-# convert a collection of mp3 files to wave or cdr,
+# convert a collection of mp3 files to wave or cdr,
# e.g. file.wav -> file.mp3)
$ for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
-
+
# Download with LaTeX2HTML created Files (for example the ZSH-Guide):
$ for f in http://zsh.sunsite.dk/Guide/zshguide{,{01..08}}.html; do
> lynx -source $f >${f:t}
> done
-# Move all files in dir1 and dir2 that have line counts greater than 10 to
+# Move all files in dir1 and dir2 that have line counts greater than 10 to
# another directory say "/more10"
$ mv dir[12]/**/*.cr(-.e{'((`wc -l < $REPLY` > 10))'}) /more10
@@ -446,7 +454,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
$ char=N ; print $((#char))
# Filename "Erweiterung"
-# Note: The (N) says to use the nullglob option for this particular
+# Note: The (N) says to use the nullglob option for this particular
# glob pattern.
$ for i in *.o(N); do
> rm $i
@@ -466,9 +474,9 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
# gzip files when containing a certain string
$ gzip ${(ps:\0:)"$(grep -lZ foobar ./*.txt(.))"}
-# A small one-liner, that reads from stdin and prints to stdout the first
-# unique line i. e. does not print lines that have been printed before
-# (this is similar to the unique command, but unique can only handle
+# A small one-liner, that reads from stdin and prints to stdout the first
+# unique line i. e. does not print lines that have been printed before
+# (this is similar to the unique command, but unique can only handle
# adjacent lines).
$ IFS=$'\n\n'; print -rl -- ${(Oau)${(Oa)$(cat file;echo .)[1,-2]}}
@@ -492,7 +500,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details.
(Recursive) Globbing - Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A list of valid glob Qualifiers can be found in zshexpn(1). *Note:*
-\*\*/ is equivalent to (*/)#! For example:
+\*\*/ is equivalent to (*/)#! For example:
-------------------------------------------------------------------------------
$ print (*/)#zsh_us.ps
zsh-4.2.3/Doc/zsh_us.ps
@@ -504,7 +512,7 @@ zsh-4.2.3/Doc/zsh_us.ps
# Search for `README' in all Subdirectories
$ ls -l **/README
-# find directories that contain both "index.php" and "index.html", or in
+# find directories that contain both "index.php" and "index.html", or in
# general, directories that contain more than one file matching "index.*"
$ ls **/*(D/e:'[[ -e $REPLY/index.php && -e $REPLY/index.html ]]':)
# or
@@ -516,12 +524,12 @@ zsh-4.2.3/Doc/zsh_us.ps
$ find / | grep -e /path/ -e '/path$'
# Print he path of the directories holding the ten biggest C regular files
-# in the current directory and subdirectories.
- $ print -rl -- **/*.c(D.OL[1,10]:h) | sort -u
+# in the current directory and subdirectories.
+ $ print -rl -- **/*.c(D.OL[1,10]:h) | sort -u
# Find files with size == 0 and send a mail
- $ files=(**/*(ND.L0m+0m-2))
- > (( $#files > 0 )) && print -rl -- $files | \
+ $ files=(**/*(ND.L0m+0m-2))
+ > (( $#files > 0 )) && print -rl -- $files | \
mailx -s "empty files" foo@bar.tdl
# recursive chmod
@@ -535,8 +543,8 @@ zsh-4.2.3/Doc/zsh_us.ps
$ list=(${1:[...]}/*(ND:t))
$ (($#list)) && print -rC2 -- ${(V)list}
-# Search all files in /home/*/*-mail/ with a setting ``chmod -s'' flag
-# (recursive, include dotfiles) remove the setgid/setuid flag and print
+# Search all files in /home/*/*-mail/ with a setting ``chmod -s'' flag
+# (recursive, include dotfiles) remove the setgid/setuid flag and print
# a message
$ chmod -s /home/*/*-mail(DNs,S) /home/*/*-mail/**/*(DNs,S))
# or with a small script
@@ -544,14 +552,14 @@ zsh-4.2.3/Doc/zsh_us.ps
> print -r -- $file
> chmod -s $file && print -r fixed $file
> }
-# or use ``zargs'' (require autoload zargs) prevent the arg list too
+# or use ``zargs'' (require autoload zargs) prevent the arg list too
# long error
$ zargs /home/*/*-mail(DNs,S) /home/*/*-mail/**/*(DNs,S)) -- chmod -s
# List files beginning at `foo23' upwards (foo23, foo24, foo25, ..)
$ ls -l foo<23->
-# get all files that begin with the date strings from June 4 through
+# get all files that begin with the date strings from June 4 through
# June 9 of 2004
$ ls -l 200406{04..10}*(N)
# or if they are of the form 200406XX (require ``setopt extended_glob''
@@ -576,7 +584,7 @@ zsh-4.2.3/Doc/zsh_us.ps
# List files in the current directory are not writable by the owner
$ print -l ~/*(ND.^w)
-# find and delete the files which are older than a given parameter
+# find and delete the files which are older than a given parameter
# (seconds/minutes/hours)
# deletes all regular file in /Dir that are older than 3 hours
$ rm -f /Dir/**/*(.mh+3)
@@ -588,23 +596,23 @@ zsh-4.2.3/Doc/zsh_us.ps
$ rm ./**/*(.Dmh+1,.DL0)
# deletes all files more than 6 hours old
$ rm -f **/*(mh+6)
- # removes all files but the ten newer ones (delete all but last 10
+ # removes all files but the ten newer ones (delete all but last 10
# files in a directory)
$ rm ./*(Om[1,-11])
- Note: If you get a arg list too long, you use the builtin rm. For
+ Note: If you get a arg list too long, you use the builtin rm. For
example:
$ zmodload zsh/files ; rm -f **/*(mh+6)
or use the zargs function:
$ autoload zargs ; zargs **/*(mh+6) -- rm -f
-# A User's Guide to the Z-Shell /5.9: Filename Generation and Pattern
-# Matching find all files in all subdirectories, searching recursively,
-# which have a given name, case insensitive, are at least 50 KB large,
-# no more than a week old and owned by the root user, and allowing up
-# to a single error in the spelling of the name. In fact, the required
+# A User's Guide to the Z-Shell /5.9: Filename Generation and Pattern
+# Matching find all files in all subdirectories, searching recursively,
+# which have a given name, case insensitive, are at least 50 KB large,
+# no more than a week old and owned by the root user, and allowing up
+# to a single error in the spelling of the name. In fact, the required
# expression looks like this:
$ ls **/(#ia1)name(LK+50mw-1u0)
-
+
# Change the UID from 102 to 666
$ chown 666 **/*(u102)
@@ -623,7 +631,7 @@ zsh-4.2.3/Doc/zsh_us.ps
# Show only empty files which nor `group' or `world writable'
$ ls *(L0f.go-w.)
-# find - and list - the ten newest files in directories and subdirs
+# find - and list - the ten newest files in directories and subdirs
# (recursive)
$ print -rl -- **/*(Dom[1,10])
@@ -632,14 +640,14 @@ zsh-4.2.3/Doc/zsh_us.ps
# display the 5-10 last modified files
$ print -rl -- /path/to/dir/**/*(D.om[5,10])
-
+
# find all files without a valid owner
$ chmod someuser /**/*(D^u:${(j.:u:.)${(f)"$( head (dirname)
:t --> tail (basename)
- :r --> rest (extension removed)
+ :r --> rest (extension removed)
$ for f (*.sh) mv $f $f:r
# Remove a filename extension of the form `.xxx', leaving the root name.
@@ -687,7 +695,7 @@ for details.
$ echo $foo:e
42
-# Print the new command but do not execute it. Only works with history
+# Print the new command but do not execute it. Only works with history
# expansion.
$ echo =ls(:h)
/bin
@@ -735,7 +743,7 @@ See zshmisc(1) for more informations (or less ${^fpath}/zmv(N))
# Redirect output to a file AND display on screen
$ foobar >&1 > file1 > file2 > ..
-
+
# pipe single output to multiple inputs
$ zcat foobar.Z >> (gzip -9 > file1.gz) \
>> (bzip2 -9 > file1.bz2) \
@@ -752,9 +760,9 @@ See zshmisc(1) for more informations (or less ${^fpath}/zmv(N))
$ setopt multios
$ process1 > >(process1) > >(process2)
-# initializing a variable and simultaneously keeping terminal output
+# initializing a variable and simultaneously keeping terminal output
$ setopt multios
- $ { a=$(command >&1 >& 3 3 > &- 2>&1);} 3>&1
+ $ { a=$(command >&1 >& 3 3 > &- 2>&1);} 3>&1
# redirect stderr two times
$ setopt multios ; program 2> file2 > file1 2>&1
@@ -766,7 +774,7 @@ See zshmisc(1) for more informations (or less ${^fpath}/zmv(N))
$ command 2>&2 2>stderr
# redirect stderr and stdout to separate files and both to orig. stdout:
$ command 2>&1 1>&1 2>stderr 1>stdout
-# redirect stderr and stdout to separate files and stdout to orig. stdout
+# redirect stderr and stdout to separate files and stdout to orig. stdout
# AND stderr to orig. stderr:
$ command 2>&2 1>&1 2>stderr 1>stdout
@@ -787,7 +795,7 @@ ZMV-Examples (require autoload zmv)
$ ls *
1.c 1.foo 2.foo 3.foo 4.foo foo.fnord
-# Rename "file.with.many.dots.txt" by substituting dots (exept for the last
+# Rename "file.with.many.dots.txt" by substituting dots (exept for the last
# one!) with a space
$ touch {1..20}-file.with.many.dots.txt
$ zmv '(*.*)(.*)' '${1//./ }$2'
@@ -795,9 +803,9 @@ ZMV-Examples (require autoload zmv)
# Remove the first 4 chars from a filename
$ zmv -n '*' '$f[5,-1]' # NOTE: The "5" is NOT a mistake in writing!
-# Rename names of all files under the current Dir to lower case, but keep
-# dirnames as-is.
- $ zmv -Qv '(**/)(*)(.D)' '$1${(L)2}'
+# Rename names of all files under the current Dir to lower case, but keep
+# dirnames as-is.
+ $ zmv -Qv '(**/)(*)(.D)' '$1${(L)2}'
# replace all 4th character, which is "1", with "2" and so on
$ autoload -U zmv
@@ -807,30 +815,30 @@ ZMV-Examples (require autoload zmv)
$ touch 111111111111111{a-z}
$ autoload zmv
$ zmv '*' '$f[16,-1]'
-
+
# Replace spaces (any number of them) with a single dash in file names
$ autload zmv
- $ zmv -n '(**/)(* *)' '$1${2//( #-## #| ##)/-}'
+ $ zmv -n '(**/)(* *)' '$1${2//( #-## #| ##)/-}'
# or - with Bash
- $ find . -depth -name '* *' -exec bash -c '
- > shopt -s extglob
+ $ find . -depth -name '* *' -exec bash -c '
+ > shopt -s extglob
> file=$1
- > dir=${file%/*}
+ > dir=${file%/*}
> name=${file##*/}
> newname=${name//*([ -]) *([ -])/-}
- > mv -i -- "$file" "$Dir/$newname"' {} {} \;
+ > mv -i -- "$file" "$Dir/$newname"' {} {} \;
# Clean up file names and remove special characters
- $ autoload zmv
- $ zmv -n '(**/)(*)' '$1${2//[^A-Za-z0-9._]/_}'
+ $ autoload zmv
+ $ zmv -n '(**/)(*)' '$1${2//[^A-Za-z0-9._]/_}'
-# Add *.py to a bunch of python scripts in a directory (some of them end
+# Add *.py to a bunch of python scripts in a directory (some of them end
# in *.py and give them all a proper extension
- $ autoload zmv
+ $ autoload zmv
$ zmv -n '(**/)(con*)(#qe,file $REPLY | grep "python script",)' '$1$2.py'
# lowercase all extensions (i. e. *.JPG) incl. subfolders
- $ autoload zmv
+ $ autoload zmv
$ zmv '(**/)(*).(#i)jpg' '$1$2.jpg'
# Or - without Zsh
$ find Dir -name '*.[jJ][pP][gG]' -print | while read f
@@ -842,7 +850,7 @@ ZMV-Examples (require autoload zmv)
> done
# remove leading zeros from file extension
- $ autoload zmv
+ $ autoload zmv
$ ls
filename.001 filename.003 filename.005 filename.007 filename.009
filename.002 filename.004 filename.006 filename.008 filename.010
@@ -850,76 +858,76 @@ ZMV-Examples (require autoload zmv)
$ ls
filename.1 filename.10 filename.2 filename.3 filename.4 filename.5 ..
-# renumber files.
- $ autoload zmv
+# renumber files.
+ $ autoload zmv
$ ls *
foo_10.jpg foo_2.jpg foo_3.jpg foo_4.jpg foo_5.jpg foo_6.jpg ..
$ zmv -fQ 'foo_(<0->).jpg(.nOn)' 'foo_$(($1 + 1)).jpg'
$ ls *
foo_10.jpg foo_11.jpg foo_3.jpg foo_4.jpg foo_5.jpg ...
-# adding leading zeros to a filename (1.jpg -> 001.jpg, ..
- $ autoload zmv
+# adding leading zeros to a filename (1.jpg -> 001.jpg, ..
+ $ autoload zmv
$ zmv '(<1->).jpg' '${(l:3::0:)1}.jpg'
# See above, but now only files with a filename >= 30 chars
- $ autoload zmv
+ $ autoload zmv
$ c=1 zmv "${(l:30-4::?:)}*.foo" '$((c++)).foo'
# Replace spaces in filenames with a underline
- $ autoload zmv
+ $ autoload zmv
$ zmv '* *' '$f:gs/ /_'
# Change the suffix from *.sh to *.pl
- $ autoload zmv
+ $ autoload zmv
$ zmv -W '*.sh' '*.pl'
# Add a "".txt" extension to all the files within ${HOME}
# ``-.'' is to only rename regular files or symlinks to regular files,
# ``D'' is to also rename hidden files (dotfiles))
- $ autoload zmv
+ $ autoload zmv
$ zmv -Q '/home/**/*(D-.)' '$f.txt'
# Or to only rename files that don't have an extension:
$ zmv -Q '/home/**/^?*.*(D-.)' '$f.txt'
# Recursively change filenames with characters ? [ ] / = + < > ; : " , - *
- $ autoload zmv
+ $ autoload zmv
$ chars='[][?=+<>;",*-]'
$ zmv '(**/)(*)' '$1${2//$~chars/%}'
# Removing single quote from filenames (recursively)
- $ autoload zmv
+ $ autoload zmv
$ zmv -Q "(**/)(*'*)(D)" "\$1\${2//'/}"
-# When a new file arrives (named file.txt) rename all files in order to
-# get (e. g. file119.txt becomes file120.txt, file118.txt becomes
+# When a new file arrives (named file.txt) rename all files in order to
+# get (e. g. file119.txt becomes file120.txt, file118.txt becomes
# file119.txt and so on ending with file.txt becoming file1.txt
- $ autoload zmv
+ $ autoload zmv
$ zmv -fQ 'file([0-9]##).txt(On)' 'file$(($1 + 1)).txt'
# lowercase/uppercase all files/directories
- $ autoload zmv
+ $ autoload zmv
$ zmv '(*)' '${(L)1}' # lowercase
$ zmv '(*)' '${(U)1}' # uppercase
# Remove the suffix *.c from all C-Files
- $ autoload zmv
+ $ autoload zmv
$ zmv '(*).c' '$1'
# Uppercase only the first letter of all *.mp3 - files
- $ autoload zmv
+ $ autoload zmv
$ zmv '([a-z])(*).mp3' '${(C)1}$2.mp3'
# Copy the target `README' in same directory as each `Makefile'
- $ autoload zmv
+ $ autoload zmv
$ zmv -C '(**/)Makefile' '${1}README'
# Removing single quote from filenames (recursively)
- $ autoload zmv
+ $ autoload zmv
$ zmv -Q "(**/)(*'*)(D)" "\$1\${2//'/}"
# Rename pic1.jpg, pic2.jpg, .. to pic0001.jpg, pic0002.jpg, ..
- $ autoload zmv
+ $ autoload zmv
$ zmv 'pic(*).jpg' 'pic${(l:4::0:)1}.jpg'
$ zmv '(**/)pic(*).jpg' '$1/pic${(l:4::0:)2}.jpg' # recursively
-------------------------------------------------------------------------------
@@ -933,8 +941,8 @@ zsh/pcre (require zmodload zsh/pcre)
-------------------------------------------------------------------------------
# Copy files of a certain period (date indicated in the filenames)
- $ zmodload zsh/pcre
- $ ls -d -- *(e:'[[ $REPLY -pcre-match pcre-regexp ]]':)
+ $ zmodload zsh/pcre
+ $ ls -d -- *(e:'[[ $REPLY -pcre-match pcre-regexp ]]':)
# or
$ m() { [[ $1 -pcre-match pcre-regexp ]] }
$ ls -d -- *(+m)
@@ -943,7 +951,7 @@ zsh/pcre (require zmodload zsh/pcre)
zsh/clone (require zmodload zsh/clone)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------------------------------------------------------------
-# Creates a forked instance of the current shell ($! is set to zero) and
+# Creates a forked instance of the current shell ($! is set to zero) and
# execute ``command'' on /dev/tty8 (for this example).
$ zmodload zsh/clone
$ clone /dev/tty8 && (($! == 0)) && exec command
@@ -961,20 +969,20 @@ zsh/datetime (require zmodload zsh/datetime)
$ $ zmodload zsh/datetime
$ setopt extendedglob
$ touch aaa_bbb_20041212_c.dat eee_fff_20051019_g.dat
- $ strftime -s pattern \
+ $ strftime -s pattern \
'???_???_<0-%Y%m%d>_?.dat' $((EPOCHSECONDS - 365 * 24 * 60 * 60 / 2))
$ print -rl -- $~pattern
aaa_bbb_20041212_c.dat
- $ print -rl -- $pattern
+ $ print -rl -- $pattern
???_???_<0-20050815>_?.dat
-# Search files size == 0, to be based on the file name containing a date
+# Search files size == 0, to be based on the file name containing a date
# rather than the "last modified" date of the file
- $ zmodload -i zsh/datetime
- $ strftime -s file "abc_de_%m%d%Y.dat" $((EPOCHSECONDS - 24 * 60 * 60 ))
- $ files=(**/$file(N.L0))
- $ (( $#files > 0 )) && print -rl -- $files | \
- mailx -s "empty files" foo@bar.tdl
+ $ zmodload -i zsh/datetime
+ $ strftime -s file "abc_de_%m%d%Y.dat" $((EPOCHSECONDS - 24 * 60 * 60 ))
+ $ files=(**/$file(N.L0))
+ $ (( $#files > 0 )) && print -rl -- $files | \
+ mailx -s "empty files" foo@bar.tdl
-------------------------------------------------------------------------------
zsh/stat (require zmodload zsh/stat)
@@ -985,7 +993,7 @@ zsh/stat (require zmodload zsh/stat)
$ file1=foo
$ file2=bar
$ touch bar & sleep 5 & touch foo
- $ echo $file1 is $(($(stat +mtime $file2) - \
+ $ echo $file1 is $(($(stat +mtime $file2) - \
$(stat +mtime $file1))) seconds older than $file2.
bar is 5 seconds older than foo
@@ -998,7 +1006,7 @@ zsh/stat (require zmodload zsh/stat)
$ zmodload zsh/stat
$ ls -fld ./**/*(d`stat +device .`OL[1,100])
-# Get only the user name and the file names from (like
+# Get only the user name and the file names from (like
# ls -l * | awk '{print $3" " $8}')
$ zmodload zsh/stat
$ for file; do
@@ -1017,21 +1025,21 @@ zsh/stat (require zmodload zsh/stat)
# ``[1]'': return only first one
$ zmodload zsh/stat
$ stat +size ./*(DOL[1])
-
+
# file size in bytes
$ zmodload zsh/stat
$ stat -L +size ~/.zshrc
4707
# Delete files in a directory that hasn't been accessed in the last ten days
-# and send ONE mail to the owner of the files informing him/her of the files'
+# and send ONE mail to the owner of the files informing him/her of the files'
# deletion.
$ zmodload zsh/stat zsh/files
$ typeset -A f; f=()
$ rm -f /path/**/*(.a+10e{'stat -sA u +uidr $REPLY; f[$u]="$f[$u]$REPLY"'})
$ for user (${(k)f}) {print -rn $f[$user]|mailx -s "..." $user}
-# Get a "ls -l" on all the files in the tree that are younger than a
+# Get a "ls -l" on all the files in the tree that are younger than a
# specified age
$ zmodload zsh/stat
$ for d (. ./**/*(N/m-2))
@@ -1048,13 +1056,13 @@ zsh/stat (require zmodload zsh/stat)
$ stat -F '%d %m %Y' +mtime ~/.zshrc
30 06 2004
$ stat -F '%D' +mtime ~/.zshrc
- 06/30/04
+ 06/30/04
-------------------------------------------------------------------------------
zsh/files (require zmodload zsh/files)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------------------------------------------------------------
-# search a directory for files containing a certain string then copy those
+# search a directory for files containing a certain string then copy those
# files to another directory.
$ zmodload zsh/files
$ IFS=$'\0'
@@ -1068,7 +1076,7 @@ zsh/mapfile (require zmodload zsh/mapfile)
$ zmodload zsh/mapfile
$ pattern1="foo"
$ pattern2="bar foo"
- $ print -l ./**/*(DN.e{'z=$mapfile[$REPLY] && [[ $z = *$pattern1* && \
+ $ print -l ./**/*(DN.e{'z=$mapfile[$REPLY] && [[ $z = *$pattern1* && \
$z = *$pattern2* ]]'})
# or a solution in combination with zsh/pcre
$ zmodload -i zsh/mapfile zsh/pcre
@@ -1085,10 +1093,10 @@ zsh/mapfile (require zmodload zsh/mapfile)
# or - for case insensitive
$ setopt extendedglob
$ print -rl -- ${${=mapfile[/etc/passwd]}:#*(#i)root*}
-
-# If a XML-file contains stuff like ``'' and ``'', number
-# this empty tags (ones ending in '/>') so if encountered in the same
-# order, the preceeding tags would become ``1'' and
+
+# If a XML-file contains stuff like ``'' and ``'', number
+# this empty tags (ones ending in '/>') so if encountered in the same
+# order, the preceeding tags would become ``1'' and
# ``2''
$ zmodload zsh/mapfile
$ cnt=0
@@ -1097,10 +1105,10 @@ zsh/mapfile (require zmodload zsh/mapfile)
# removing all files in users Maildir/new that contain ``filename="gone.src''
$ zmodload zsh/{files,mapfile}
- $ rm -f /u1/??/*/Maildir/new/100*(.e{'[[ $mapfile[$REPLY] == \
+ $ rm -f /u1/??/*/Maildir/new/100*(.e{'[[ $mapfile[$REPLY] == \
*filename=\"gone.scr\"* ]]'})
-# Grep out the Title from a postscript file and append that value to the
+# Grep out the Title from a postscript file and append that value to the
# end of the filename
$ autoload -U zmv
$ zmodload zsh/mapfile
@@ -1113,7 +1121,7 @@ zsh/mathfunc (require zmodload zsh/mathfunc)
$ zmodload zsh/mathfunc
$ echo $(( sin(1/4.0)**2 + cos(1/4.0)**2 - 1 ))
-1.1102230246251565e-16
-$ echo $(( pi = 4.0 * atan(1.0) ))
+$ echo $(( pi = 4.0 * atan(1.0) ))
3.1415926535897931
$ echo $(( f = sin(0.3) ))
0.29552020666133955
@@ -1176,9 +1184,9 @@ zsh/zftp (require zmodload zsh/zftp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------------------------------------------------------------
$ autoload -U zfinit
- $ zfinit
+ $ zfinit
$ zfparams www.example.invalid myuserid mypassword
- $ zfopen
+ $ zfopen
$ zfcd tips
$ zfls -l zshtips.html
$ zfput zshtips.html
@@ -1204,15 +1212,15 @@ zsh/zftp (require zmodload zsh/zftp)
> zfget $file
$ done
$ zfclose
-
-# Upload all regular files in $HOME/foobar (recursive) that are newer than
+
+# Upload all regular files in $HOME/foobar (recursive) that are newer than
# two hours to ftp.foobar.invalid/path/to/upload
$ autoload -U zfinit ; zfinit
$ zfopen ftp.foobar.invalid/path/to/upload
$ cd $HOME/foobar
$ zfput -r **/*(.mh-2)
$ zfclose
-
+
# long list of files on a ftp
$ autoload -U zfinit ; zfinit
$ zfopen some-host
@@ -1341,7 +1349,7 @@ caption always "%3n %t%? (%u)%?%?: %h%?"
Special variables which are assigned:
------------------------------------------------------
-$LINENO $RANDOM $SECONDS $COLUMNS $HISTCHARS $UID
+$LINENO $RANDOM $SECONDS $COLUMNS $HISTCHARS $UID
$EUID $GID $EGID $USERNAME $fignore $mailpath $cdpath
------------------------------------------------------
@@ -1394,7 +1402,8 @@ Adam's ZSH page::
Zzappers Best of ZSH Tips::
*http://www.rayninfo.co.uk/tips/zshtips.html[]*
Zsh Webpage by Christian Schneider::
- *http://strcat.de/zsh/[]*
+ *http://strcat.de/wiki/zsh/[]*
+ *http://strcat.de/wiki/zsh-german[]* (German translation. Help needed!)
The zsh-lovers webpage::
*http://grml.org/zsh/[]*
IRC channel::
@@ -1417,7 +1426,7 @@ Barton E. Schaefer - http://www.well.com/user/barts/
Matthias Kopfermann - http://www.infodrom.north.de/~matthi/
Oliver Kiddle - http://people.freenet.de/opk/
Paul Falstad - http://www.falstad.com/
-Peter Stephenson - http://python.swan.ac.uk/~pypeters/
+Peter Stephenson - http://homepage.ntlworld.com/p.w.stephenson/
Richard Coleman
Stephane Chazelas - http://stephane.chazelas.free.fr/
Sven Guckes - http://www.guckes.net/
@@ -1428,17 +1437,21 @@ SEE ALSO
--------
Manpages of zsh:
------------------------------------------------------------------
- zsh Zsh overview (this section)
+ zsh Zsh overview
+ zshall Tthe Z shell meta-man page
+ zshbuiltins Zsh built-in commands
+ zshcompctl Zsh completion control
+ zshcompsys Zsh completion system
+ zshcompwid Zsh completion widgets
+ zshcontrib User contributions to zsh
+ zshexpn Zsh expansion and substitution
zshmisc Anything not fitting into the other sections
- zshexpn Zsh command and parameter expansion
- zshparam Zsh parameters
+ zshmodules Zsh loadable modules
zshoptions Zsh options
- zshbuiltins Zsh built-in functions
+ zshparam Zsh parameters
+ zshroadmap Informal introduction to the zsh manual
+ zshtcpsys Zsh tcp system
zshzle Zsh command line editing
- zshcompwid Zsh completion widgets
- zshcompsys Zsh completion system
- zshcompctl Zsh completion control
- zshmodules Zsh loadable modules
zshzftpsys Zsh built-in FTP client
zshall Meta-man page containing all of the above
------------------------------------------------------------------