home

Quickies, by Andrea Olivato

text

Bash tricks & tips

The following examples are not difficult coding examples, but just quick reminders to make working with bash easier and quicker.


# Use last argument of previous command
touch somefile
vim !$

# Monitor code execution
/bin/bash -x command 
# or declare it at the top of the script
#!/bin/bash -x

# Repeat previous command changing a world with an other
for i in $(seq 0 10); do mv somefile.somext somefile.newext; done;
^ somext ^ somotherext^

# Rename a file to file.bak
mv file{,.bak}


# Create a directory and all the needed path if not exists yet
mkdir -p /non-existing/path/to/dir

# Lists all backgrounded processes in this shell
jobs

2 years ago

August 3, 2009
Comments (View)
blog comments powered by Disqus