Useful unix commands

Published on 20-08-2013 in [ unix, commandline ]

rename files with spaces

IFS=$'\n';for file in `find . -regex ".*([0-9]).jpg"`; do new=$(echo $file | sed "s:[0-9]:0&:");mv $file $new;done;unset IFS
IFSS="$(printf '\n\t')";for f in 01*; do mv $f 0$f; done

xrandr

xrandr --output VGA1 --auto --left-of LVDS1

CTRL right key does not work with oss keymap

sudo vim /usr/share/X11/xkb/symbols/fr
// include "level5(rctrl_switch)"

debug msmtp ::

msmtp -d --serverinfo --host=tibre.lip6.fr --port=465 --tls=on --auth=login --user= --tls-starttls=off --tls-certcheck=off --timeout=60

renommer des fichiers qui contiennent des espaces (il faut modifier IFS, par defaut à space,tab,newline, pour que space ne soit plus un separateur) ::

IFS=$'\n';for file in find . -regex ".*([0-9]).jpg"; do new=$(echo $file | sed "s:[0-9]:0&:");mv $file $new;done;unset IFS

dates

date -d "1970-01-01 UTC + 1164128484 seconds" date -d "2010-08-12" +%s

files with hyphen - tiret ::

mv -- -foo bar # rename -foo in bar

test alsa ::

aplay /usr/share/sounds/alsa/Front_Center.wav

articles cites qu'une fois dans un tex ::

cat article_submitted.tex | grep -v "^%" | grep -i "cite" | sed "s:.cite{:: " | sed "s:}.::" | sed "s:,|\s:\n:g" | sort | uniq -u

infos systeme

  • Carte mère et Bios (en root) : :command:dmidecode
  • RAM : :command:free -m
  • Processeur : :command:lscpu - cat /proc/cpuinfo
  • Carte graphique : :command:lspci | grep VGA
  • Liste des périphériques du bus PCI : :command:lspci
  • Liste des périphériques USB : :command:lsusb
  • Interfaces réseau : :command:ifconfig
  • Espace disque et pourcentage d'occupation : :command:df -h
  • Partition swap : :command:swapon -s
  • Machine (noyau, nom de machine...) : :command:uname -a
  • Informations de fonctionnement : :command:uptime, :command:top, :command:ps, :command:who, :command:vmstat ...

utf8 latin1 vim

:w ++enc=utf-8

match vim all lines :

for all lines (g) with pattern /url/, s[ubstitute] amazon by # fnac

g/url/ s/amazon/fnac/

capslock as escape key

setxkbmap -option caps:escape