...
Code Block | ||
---|---|---|
| ||
# Use parentheses to capture part of the search pattern: cat joblist.txt | head | \ perl -pe '~s/JA(\d+)\tSA(\d+)/Job $1 on Run $2/' # Illustrate use of optional modifiers head joblist.txt | perl -pe 's/0/-/' # replaces only the 1st 0 on a line head joblist.txt | perl -pe 's/0/-/g' # replaces all 0s on each line head joblist.txt | perl -pe 's/ja/Job /i' # performs case-insensitive search head joblist.txt | perl -pe ' s/ja\d\d(\d\d\d).*Sa(\d\d)(\d\d\d)/year 20$2, run $3 job $2$1/i' |
Exercise 3-9
Oops – we misspelled a walrus name: Antje should be Antie in ~/data/walrus_sounds.tsv. Use perl pattern substitution to fix this.
...