Skip to content

Instantly share code, notes, and snippets.

@horaciod
Created May 22, 2024 14:37
Show Gist options
  • Save horaciod/d2720fe300336204f5a885dbf641c712 to your computer and use it in GitHub Desktop.
Save horaciod/d2720fe300336204f5a885dbf641c712 to your computer and use it in GitHub Desktop.
Extrae las lineas entre dos palabras ingresadas entrepalabras.sh archivo.txt p1 p2
#! /bin/bash
archi=$1
t1=$2
t2=$3
linea=`grep -n "\[$2\]" $archi `
#separador
IFS=':'
# Read the split words into an array
# based on space delimiter
read -ra newarr <<< "$linea"
nlinea="${newarr[0]}"
linea2=`grep -n "\[$3\]" $archi `
read -ra newarr <<< "$linea2"
nlinea2="${newarr[0]}"
#tail --lines=+$nlinea $1 |head -$nlinea2
cat $1 |sed -n "${nlinea},$((nlinea2-1))p"
@horaciod
Copy link
Author

ejemplo
entre.sh config.php OAI Proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment