Drop some left over merge crap
[zsh-lovers.git] / zsh-lovers.1.txt
index 7394eee..8f874d7 100644 (file)
@@ -210,6 +210,27 @@ Hint: A list of valid glob Qualifiers can be found in zshexpn(1).
 See ``man 1 zshexpn | less -p'' Qualifiers for details.
 
 -------------------------------------------------------------------------------
+# Get the names of all files that *don't* match a pattern *anywhere* on the
+# file (and without ``-L'' because its GNUish)
+  $ print -rl -- *(.^e{'grep -q pattern $REPLY'}) 
+  # or
+  $ : *(.e{'grep -q pattern $REPLY || print -r -- $REPLY'}) 
+
+# random numbers
+  $ echo $[${RANDOM}%1000]     # random between 0-999
+  $ echo $[${RANDOM}%11+10]    # random between 10-20
+  $ echo ${(l:3::0:)${RANDOM}} # N digits long (3 digits)
+
+# reverse a word
+  $ echo "${(j::)${(@Oa)${(s::):-hello}}}"
+
+# Show newest directory
+  $ ls -ld *(/om[1])
+
+# random array element
+  $ FILES=( .../files/* )
+  $ feh $FILES[$RANDOM%$#FILES+1]
+
 # cat first line in all files in this dir
   $ for file (*(ND-.)) IFS= read -re < $file
 
@@ -682,7 +703,6 @@ Modifiers are a powerful mechanism that let you modify the results
 returned by parameter, filename and history expansion. See zshexpn(1)
 for details.
 -------------------------------------------------------------------------------
-<<<<<<< /home/dope/download/Source/HG-Repos/zsh-lovers/zsh-lovers.1.txt.orig.432616858
 # NOTE: Zsh 4.3.4 needed!
 $ autoload -U age
 # files modified today
@@ -702,12 +722,7 @@ $ autoload -U age
 # Supply times.
   $ print *(e-age 2006/10/04:10:15 2006/10/04:10:45-)
 
-# Remove a trailing pathname component, leaving the head. This works like 
-||||||| /tmp/zsh-lovers.1.txt~base.AvW_ZW
-# Remove a trailing pathname component, leaving the head. This works like 
-=======
 # Remove a trailing pathname component, leaving the head. This works like
->>>>>>> /tmp/zsh-lovers.1.txt~other.vDaddL
 # `dirname'.
   $ echo =ls(:h)
   /bin
@@ -767,7 +782,7 @@ $ autoload -U age
 
 # convert 1st char of a word to uppercase
   $ foo="one two three four"
-  $ print -r -- "${(C)var}"
+  $ print -r -- "${(C)foo}"
   One Two Three Four
 -------------------------------------------------------------------------------
 
@@ -829,6 +844,21 @@ ZMV-Examples (require autoload zmv)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *Note:* '-n' means no execution (just print what would happen). At
 -------------------------------------------------------------------------------
+# Remove illegal characters in a fat32 file system. Illegal characters are
+#   / :  ;  *  ?  "  <  >  |
+# NOTE: ``-Q'' and (D) is to include hidden files.
+  $ unwanted='[:;*?\"<>|]' 
+  $ zmv -Q "(**/)(*$~unwanted*)(D)" '$1${2//$~unwanted/}' 
+
+# Changing part of a filename (i. e. "file-hell.name" -> "file-heaven.name")
+  $ zmv '(*)hell(*)' '${1}heaven${2}'
+  # or
+  $ zmv '*' '$f:s/hell/heaven/'
+
+# remove round bracket within filenames
+# i. e. foo-(bar).avi -> foo-bar.avi
+  $ zmv '*' '${f//[()]/}'
+
 # serially all files (foo.foo > 1.foo, fnord.foo > 2.foo, ..)
   $ autoload zmv
   $ ls *