Find Jobs
Hire Freelancers

bash sed find and replace -- 2

$20-50 USD

En curso
Publicado hace casi 8 años

$20-50 USD

Pagado a la entrega
I need a bash script to do this: I have folder that contain html files and subfolders. now files name as [login to view URL], [login to view URL] etc. i want to replace the original file name with the title tag of the file ( instead of the space between the words i would like to add "_". then replace all links in all folder that contain the original name with the new title name. example of title - <title>admin/environment/php some text</title> change to <title>php_some_text</title> then to replace all links in all files that contain the old links to the new file name that will be php_some_text.html. all my needs have a solutions in my script but don't know how to replace the link all over to the new file name. my script: #!/bin/bash cd /var/www/clients/client1/web2/web/docs/31/en find . -name "*.html" > [login to view URL] while read -r filepath ; do # Considering the subfolder can have spaces, # We will start by separating the filename # And dirname folderpath=`dirname "$filepath"` filename=`basename "$filepath"` # With GNU GREP new_name=$(grep -oP '<title>\K.+?</title>' "$filepath" | sed 's#</title>##' | tr ' ' '_' ) #echo new_name=$(grep -oP '<title>\K.+?</title>' "$filepath" | sed 's#</title>##' | tr ' ' '_' ) # With BSD GREP (for who need the info) # new_name=$(grep -o '<title>.*</title>' $filepath | sed -e 's/<title>\(.*\)<\/title>/\1/g' | sed -e 's/$filename/$new_name/g' | tr ' ' '_') #if [[ $new_name = */* ]]; then echo "/${new_name##*}"; else echo "$new_name"; fi mv -v "$filepath" "$folderpath/`basename $new_name`.html" ### command that i tried to solve the link url issue #find /var/www/clients/client1/web2/web/docs -type f -exec sed -i 's/$filename/$new_name/g' {} \; #grep -rl '$filename' /var/www/clients/client1/web2/web/docs/31/en | xargs sed -i 's/$filename/$new_name/g' *.html #sed -i 's/$filename/$new_name/gi' *.html done < [login to view URL] Thank you
ID del proyecto: 10787828

Información sobre el proyecto

12 propuestas
Proyecto remoto
Activo hace 8 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
12 freelancers están ofertando un promedio de $43 USD por este trabajo
Avatar del usuario
Hello! I have experience with C programming and bash scripting. I would try to solve the link replacement problem with bash scripting but I also consider using C if I fail to do it with bash scripts, if you also agree. Please contact me so we can discuss more details. I would be glad to help you with this script :).
$50 USD en 1 día
4,3 (2 comentarios)
2,0
2,0
Avatar del usuario
Got 5 years of experience in linux field, working as Server Engineer and wrote tons of bash nagios alerts scripts to detect critical issues before it catches the client attention.
$50 USD en 5 días
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
nice task, i can help you with IT
$35 USD en 3 días
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
Piece of cake, would love to get it done for you Regards Scott
$45 USD en 1 día
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
I am a system admininistrator for years and I have experience as developer shell scripts (bash,sh,csh,perl).
$40 USD en 3 días
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
A proposal has not yet been provided
$35 USD en 2 días
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de ISRAEL
Kfar saba, Israel
5,0
1
Forma de pago verificada
Miembro desde ene 8, 2012

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.