Skip to content

Instantly share code, notes, and snippets.

@ryanwild
Last active November 10, 2015 07:50
Show Gist options
  • Save ryanwild/bcc0bafa61d85b6dd3db to your computer and use it in GitHub Desktop.
Save ryanwild/bcc0bafa61d85b6dd3db to your computer and use it in GitHub Desktop.
Bash Examples
#!/bin/bash
VALUES="value1","value2"
(IFS=,
for v in $VALUES; do
echo "$v"
done
)
#To append after the pattern: (-i is for inplace replace). line1 and line2 are the lines you want to append(or prepend)
sed -i '/pattern/a \
line1 \
line2' inputfile
#To prepend the lines before:
sed -i '/pattern/i \
line1 \
line2' inputfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment