Zen of the Command Line

Zen of the Command Line



Find and Replace Across Multiple Files

http://rufuspollock.org/2006/09/22/find-and-replace-across-multiple-files/

Find and Remove Broken Symbolic Links

 find -L ${directory} -type l 
 # remove the broken links
 find -L ${directory} -type l -print0 | xargs -0 rm 

Bulk rename files

For example to change files with extension mkd to rst:

find . -name ".mkd" | sed "s/(.).mkd/mv \1.mkd \1.rst/g" | sh

s3cmd

a: 2010-06-17 t: s3cmd css

# does not seem to auto-detect file type w/o prompting
s3cmd put --guess-mime-type --acl-public *.css s3://your-bucket/your-dir/

Mercurial

Stash working copy changes

1. Use shelve extension

2. Use Mercurial Queues (MQ)

# -f needed as we have local changes
hg qnew -f patch
hg qpop

# later
hg import --no-commit .hg/patches/patch
hg qdelete patch

3. Or without MQ:

hg diff > patch
hg update -C .

then import the patch later ...

2 Comments

  1. Matt
    Posted October 12, 2010 at 10:39 pm | Permalink

    For the first, consider:

    find -L ${directory} -type l -exec rm {} ;

  2. Matt
    Posted October 12, 2010 at 10:40 pm | Permalink

    (Feh. It ate my backslashes before opening and closing brace and semicolon)

Post a Comment

You must be logged in to post a comment.