Entsprechend dem Vorschlag von SierraX und Peter zur Textmanipulation, geschweifte Klammern {}
werden z. B. verwendet, um eine Variable an einen Befehl zu übergeben:
Nehmen wir an, Sie haben eine sposi.txt Datei, die die erste Zeile eines bekannten italienischen Romans enthält:
> sposi="somewhere/myfolder/sposi.txt"
> cat $sposi
Ausfluss: quel ramo del lago di como che volge a mezzogiorno
Erstellen Sie nun zwei Variablen:
# Search the 2nd word found in the file that "sposi" variable points to
> word=$(cat $sposi | cut -d " " -f 2)
# This variable will replace the word
> new_word="filone"
Ersetzen Sie nun die Wort Variableninhalt mit dem von neues_Wort in der Datei sposi.txt
> sed -i "s/${word}/${new_word}/g" $sposi
> cat $sposi
Ausfluss: quel filone del lago di como che volge a mezzogiorno
Das Wort "ramo" wurde ersetzt.