Difference between revisions of "Recommended bash aliases"

From CUC3
Jump to navigation Jump to search
import>Dw34
 
import>Jss43
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
   
 
Copying ~wales/.inputrc to your home directory will also reduce your typing. It sets up ESC then . as the last item on the previous line and ESC then , and backward search in history matching the start of what you have already typed.
 
Copying ~wales/.inputrc to your home directory will also reduce your typing. It sets up ESC then . as the last item on the previous line and ESC then , and backward search in history matching the start of what you have already typed.
  +
  +
== Function to remove filename extensions ==
  +
Place
  +
<pre>
  +
# rm filename extension
  +
function rmext() {
  +
find . -mindepth 1 -maxdepth 1 -type f | grep $1 |\
  +
sed 's/\(.*\)\..*/\1/' | xargs -I {} mv {}.$1 {};
  +
}
  +
</pre>
  +
in ~/.bash_aliases or ~/.bashrc then
  +
<pre>
  +
source ~/.bashrc
  +
</pre>
  +
Usage
  +
<pre>
  +
$ rmext <extension>
  +
</pre>
  +
Example
  +
<pre>
  +
$ ls -1
  +
first.file.test
  +
second.file.test
  +
important.file
  +
</pre>
  +
<pre>
  +
$ rmext test
  +
$ ls -1
  +
first.file
  +
second.file
  +
important.file
  +
</pre>
  +
  +
What about using the ''rename'' command?
  +
<pre>
  +
$ ls
  +
first.file.test important.file second.file.test
  +
$ rename ".test" "" *.test
  +
$ ls
  +
first.file important.file second.file
  +
</pre>
  +
(I'll note that different implementations of rename exist and the usage varies accordingly: check the manpage!)
  +
  +
== xpdf ==
  +
<pre>
  +
# fit width and set geometry
  +
alias xpdf="xpdf -z width -geometry 1000x1000"
  +
</pre>

Latest revision as of 22:29, 28 February 2009

~wales/.bashalias

Copying ~wales/.inputrc to your home directory will also reduce your typing. It sets up ESC then . as the last item on the previous line and ESC then , and backward search in history matching the start of what you have already typed.

Function to remove filename extensions

Place

# rm filename extension
function rmext() {
 find . -mindepth 1 -maxdepth 1 -type f | grep $1 |\
 sed 's/\(.*\)\..*/\1/' | xargs -I {} mv {}.$1 {};
}

in ~/.bash_aliases or ~/.bashrc then

source ~/.bashrc

Usage

$ rmext <extension>

Example

$ ls -1
first.file.test
second.file.test
important.file
$ rmext test
$ ls -1
first.file
second.file
important.file

What about using the rename command?

$ ls
first.file.test  important.file  second.file.test
$ rename ".test" "" *.test
$ ls
first.file  important.file  second.file

(I'll note that different implementations of rename exist and the usage varies accordingly: check the manpage!)

xpdf

# fit width and set geometry
alias xpdf="xpdf -z width -geometry 1000x1000"