You are currently browsing articles tagged gentoo.

Because I’m fed of searching for this kind of useful command :

$ for F in *; do E=${F:(-4)}; B=${F/$E/}; mv $F 'Wonderful.Serial.FileName.S03E'$B.'VOSTFR.HDTV.XViD.GKS'$E; done

Explanations :
E = ${F:(-4)} extracts the file extension.

B = ${F/$E/} returns the original filename without extension.

These two variables are then used to build the new filename 🙂


Another one, using sed and regular expressions :

$ for A in *.avi; do mv "$A" `echo $A | sed -r 's/^Name To Remove <ins>([0-9]</ins>(-[0-9]+)?)\.avi$/\1.avi/'`; done

Were we build a simple “mv” command with the original filename ($A) and a new filename by catching the output of echo $A | sed enclosing it with backquotes (`).

sed -r allows to use extended regular expressions.

s/you/me/ is the sed command to Subsitute you by me.

s/^Name To Remove ([0-9](-[0-9]+)?)\.avi$/\1.avi/

We match filenames like :

  • Name To Remove 123.avi (as many spaces as you want between the textual part of the name and the file number)
  • Name To Remove 123-456.avi

    We catch the subexpression between parenthesis (123 or 123-456 in this poor example) and we use it to build the new filename (thanks to ”\1” in the third part of the sed command.)

Tags: , , ,

Thanks to eix !

Note : You must be root to unmerge packages

Start by installing emerge if you don’t have it : emerge eix

Run update-eix to create or update the eix database.

Now, this… trick should work for you too 😉

eix --nocolor -c -I -C dev-ruby | cut -d " " -f 2 | grep --color=never dev-ruby | xargs emerge --unmerge

Need some explanations ?

eix -c -I -C dev-ruby extracts all installed packages from dev-ruby

cut -d " " -f 2 extracts the full package name

grep --color=never dev-ruby filters the list ignoring eix overlays info and packages count (you could also use eix -c -*... to avoid that)

xargs takes the whole packages list and send it as a list of arguments to emerge --unmerge that will unmerge all listed packages in one shot !

Tags: , ,