Username:   Password:  

Record MP3 audio via ALSA using ffmpeg

ffmpeg -f alsa -ac 2 -i hw:1,0 -acodec libmp3lame -ab 96k out.mp3

Record audio to an MP3 file via ALSA. Adjust -i argument according to arecord -l output.

Tags

audio bash mp3 recording

bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
 
 
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
 
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
 
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
 
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
 
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi
 
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color)
    PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$ '
    ;;
*)
    PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '
    ;;
esac
 
# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$ '
 
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "33]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}07"'
    ;;
*)
    ;;
esac
 
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
 
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
 
# xterm
alias xterm='xterm -ls -bg black -fg white -cr -fs 11 white -hc white rightbar'
 
alias apt-get="apt-get -o Acquire::http::Dl-Limit=25"
 
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi
 
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
 
# alias para abrir o último arquivo editado pelo vim
alias lvim="vim -c "normal '0""
 
alias cdesk="cd ${HOME}/Desktop"
 
# Dica retirada do blog do mitre
# http://jfmitre.blogspot.com/2006/05/convertendo-arquivos-utf-8-em-isso-8859.html
alias iso2utf='iconv -f iso-8859-1 -t utf-8'
alias utf2iso='iconv -f utf-8 -t iso-8859-1'
 
# mostra os dez comandos mais utilizados
# history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
 
#alias grep="grep --color=always"
# comentei por problemas com o grep
 
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi
 
#source /home/sergio/bin/funcoeszz
#export ZZPATH=/home/sergio/bin/funcoeszz
 
# Evita histórico com linhas duplicadas
export HISTCONTROL=ignoredups
 
# configuração do path
PATH=$PATH:~/bin
 
 
# para chamar o pythonrc
PYTHONSTARTUP="$HOME/.pythonstartup"
export PYTHONSTARTUP
 
 
myip (){  seuip=$(awk '/inet end/ {print $3}' <(ifconfig eth0))
	clear
	echo
	echo "  $seuip"
	sleep 3
	clear
}
 
# set o vim como editor padrão
export EDITOR=vim
export VISUAL=vim
 
CDPATH=.:..:~:~/docs/img:~/docs:~/bin:~/tmp
 
# Instalacao das Funcoes ZZ (www.funcoeszz.net)
#source /home/$USER/bin/funcoeszz
#export ZZPATH=/home/$USER/bin/funcoeszz
 
export PROMPT_COMMAND="history -a"
export HISTFILESIZE=2000
 
# manpages coloridas
# begin blinking
# export LESS_TERMCAP_mb=$'E[01;31m'
# # begin bold
# export LESS_TERMCAP_md=$'E[01;33m'
# # end mode
# export LESS_TERMCAP_me=$'E[0m'
# # begin standout-mode - info box
# export LESS_TERMCAP_so=$'E[01;41;37m'
# # end standout-mode
# export LESS_TERMCAP_se=$'E[0m'
# # begin underline
# export LESS_TERMCAP_us=$'E[01;32m'
# # end underline
# export LESS_TERMCAP_ue=$'E[0m'
 

configuração do bash

Tags

bash sehll script

Count lines recusively

wc -l `find . -name "*.php" -print` | tail -1 | awk '{print $1}'

Searches for all .php files in the current directory and all subdirectories and outputs the total amount of lines.

Tags

PHP count lines shell

Emulate dualscreen by using VNC

x2vnc {-west|-east|-north|-south} computer-ip:display-number

This command use vnc to connect to another computer and emulate an dual-screen enviroment. If vnc server needs a password, you will be prompted.

Tags

vnc bash dual screen

Monitor wifi connection

watch -d -n 3 "iw dev wlan0 station dump; iwconfig wlan0"
 

Monitoring wifi connection by watch command (refresh every 3s), displaying iw dump info and iwconfig on wireless interface "wlan0"

Copy text to the clipboard

echo 'hello world' | pbcopy
cmd + v
 

Copies text to the clipboard

Tags

bash clipboard text copy

Remove spaces from filenames

for i in *.html; do mv "$i" "`echo $i| tr -d ' '`"; done
 

Replace spaces for underscores

Tags

bash filename remove spaces

List all text files and append foo

for i in *.txt; do echo $i"foo"; done
 

Lists all files and appends "foo" to every file (only on the output).

Tags

list files bash

List all files that match this regular expression

ls | grep -e .*5.*
 

Lists all files with the number 5 in their name.

Tags

regex bash

Make filenames lowercase

for i in *.txt; do mv "$i" "`echo $i| tr [A-Z] [a-z]`"; done
 

Converts all the file names in a directory and converts them to lowercase.

Tags

bash filenames

Bash script to append a .txt extension to a filename

for i in *.log*; do mv "$i" "$i.txt"; done
 

Iterate over the current directory, get all files with .log and append .txt to the end of the entire filename:

Tags

bash files iterate filename