Emular el comando tree de dos
ls -R | grep : | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
ls -R | grep : | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
#!/bin/bash while [ true ] ; # se estará ejecutando indefinidamente do mem=`free -m |awk ‘NR==2 {print $4}’` # free -> da la memoria libre del sistema # -m : en megas # awk -> extrae texto # NR==2 : la 2ª línea # {print $4}: la 4ª columna if [ $mem -lt 10 ];…
Para renombrar un fichero: #!/bin/bash # Renombra el fichero según las etiquetas mp3, de la forma: NºCanción-Título TITLE="`id3info "$1" | grep ‘^=== TIT2’ | sed -e ‘s/.*: //g’`" #ARTIST="`id3info "$1" | grep ‘^=== TPE1’ | sed -e ‘s/.*: //g’`" #ALBUM="`id3info "$1" | grep ‘^=== TALB’ | sed -e ‘s/.*: //g’`" #YEAR="`id3info "$1" | grep ‘^===…
Se tiene el fichero: haciendo awk ‘{for(i=1;i<=NF;i++){print $i}}’ file5.txt > file5_new.txt se tiene:
# Devuelve un número aleatorio entre 1 y 100 echo $[ ( $RANDOM % 100 ) + 1 ]
#!/bin/bash # Genera una estructura html a partir de ficheros md (markdown) # 1. Genera la estructura de directorios # 2. Construye los html # 3. Genera un fichero índice con un enlace a todos los documentos OUTPUT=HTML if [ ! -d $OUTPUT ]; then mkdir $OUTPUT fi files=($(find ./ -type f -name ‘*.md’)) for…
Tenemos el fichero Si se quiere la suma de la columna col3: awk ‘BEGIN{FS="\t";count=0}{if(NR>1){count+=$3}}END{print count}’ file6.txt se obtiene: 171