find ./ -type f -name '*source-string*'

awk – pattern scanning and processing language

# ---------------------------------------------------------
# ---    :
#
echo $a |awk '{system("mkdir "$1);}'
# ---------------------------------------------------------
# ---------------------------------------------------------
# ---    :
#
grep ^XYZ ~/phat/to/application.cfg | sed 's/\"//g' | awk '{
LN_SOURCE = "~/phat/to/file."$2"";
LN_DEST = " /phat/to/alias"$2"-"$5;
print ""LN_SOURCE" "LN_DEST;
system("ln -s "LN_SOURCE" "LN_DEST);
}'
# ---------------------------------------------------------
# ---    : SET THE FILD SEPARATOR
#
awk 'BEGIN { FS = "," } ; { print $2 }'
# ---------------------------------------------------------
# ---    : FGREP
awk '/XYZ/ { print $0 }' input.file
# GNU grep -o would be perfect, but since we're talking about awk here:
# The RSTART and RLENGTH variables are the key.  Note that additional logic would be required for multiple matches on a line.

awk 'match($0,/regexp/) {print substr($0,RSTART,RLENGTH)}' inputfile

# For multiple matches on a line:

awk '/regexp/{for(i=1;i<=NF;++i)if($i~/regexp/)print $i}' /path/to/inputfile
 
# XML
# Parsing XML using shell script Shell Programming and Scripting
#
uname -a | awk '{hostname=$2 ; print hostname ; }'

awk '/Aaron/{ first_name=$2 ; second_name=$3 ; print first_name, second_name ; }' names.txt

awk -F"[<>]" '/muster_0/{a=$3} /muster_1/{b=$3} /muster_2/{c=$3} {print a,b,c}' tmp.xml

dir -l | awk '$3=="root" {print $1,$3,$4, $9;} '

cat doc.txt | awk '$4 ~ /muster_0/{print}'

#
awk '$1~"^(" s ")$"{print $2}' RS=\< FS=\> s="muster_0|muster_1|muster_2" tmp.xml
#
xmllint --xpath '//quittungsliste/quittung_item/sequenz_nr/text()|//quittungsliste/quittung_item/quittungsstatus/text()|//quittungsliste/quittung_item/meldungsliste/meldung_item/kennung/text()' - <<< $(echo "$EXTRACT_TAR_TO_RAM")`
#
xmllint --xpath '/RECORDS/RECORD/COUNTRY[text()="COUNTRY"]/following-sibling::string[position()=1]/text()
# ---------------------------------------------------------
# ---    : Insert a line before or after a pattern 
#
# Inserting before the pattern:
awk '/XYZpattern/{print "#-------"}1' file
sed 's/.*XYZpattern.*/#-------\n&/' file
# Inserting after the Pattern:
awk '/XYZpattern/{print;print "#-------";next}1' file
sed 's/.*XYZpattern.*/&\n#-------/' file
# ---------------------------------------------------------
# ---------------------------------------------------------
# ---    : SED: change/insert/append lines after matching a pattern
#
cat > filename.txt
first line
second line
third line
# --- Match “second line” pattern and append “append line” into the matched address.
sed ‘/second line/a\
append line
‘ filename.txt
# first line
# second line
# append line
# third line
# --- Match “second line” pattern and insert “insert line” to the matched address.
sed ‘/second line/i\
insert line
‘ filename.txt
# first line
# insert line
# second line
# third line
sed ‘/second line/c\
change line
‘ filename.txt
# first line
# change line
# third line
# ---------------------------------------------------------

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.