Apagada docs

Aprendiendo a programar el pasado

Herramientas de usuario

Herramientas del sitio


start:en:sed:emulate_linux_find_with_linux_ls_and_sed

Emulate linux find via linux ls -R

#!/bin/sed -n
# Emulate linux find via linux ls -R
# useful when we have to connect to some host wich does not have
# 'find' and we want to make an script to get all files.
# I use this to get a list of files to pull from my android device.
#
# If you run sed from linux, maybe you have to change ".$" into "$".
#".$" is used to remove spurious \r characters in ms-windows
# (sed for windows does not understand \r or \n).
#
#
# Use sed -n to run this script
#
#
# IN SPANISH:
#Convertir la salida de ls -R en una salida parecida a la de find:
#(Android no tiene find, solo ls -R)
# (este script elimina los \r del final de línea; puede ser necesario
# modificarlo si se usa en unix)


/[/]/{
s/\(^.*:\).*$/\1/
h
}
/[/]/!{
s/^.*$/##FIELD##&##DLEIF##/g
G
s/##FIELD##\(.*\).##DLEIF##..\(.*\):.*$/\"\2\/\1\"/g
p
}
#Explanation:
# If a line including "/" and ending with ":" is found, it is inserted into hold space.
# Then, if a line not including "/" is found:
# Line is converted into ##FIELD##<line contents>##DLEIF##
# The hold line is appended to it.b
# The text between ##FIELD## and ##DLEIF## is used as field 1, discarding last char (probably a carriage return).
# The text after ##DLEIF## up to the ":", and excluding it, is used as second field.
# The line is substituted by field2\field1
Este sitio web utiliza cookies. Al utilizar el sitio web, usted acepta almacenar cookies en su computadora. También reconoce que ha leído y entendido nuestra Política de privacidad. Si no está de acuerdo abandone el sitio web.Más información
start/en/sed/emulate_linux_find_with_linux_ls_and_sed.txt · Última modificación: 2015/07/13 07:36 por nepenthes