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 # 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…
find -type f -exec grep -l "texto_busqueda" {} + y si queremos que la búsqueda sea exacta (por palabras) find -type f -exec grep -lw "texto_busqueda" {} +
# Devuelve un número aleatorio entre 1 y 100 echo $[ ( $RANDOM % 100 ) + 1 ]
grep -m 1 -oE ‘([0-9]{1,3}\.){3}[0-9]{1,3}’
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: