Last active
April 16, 2017 11:46
-
-
Save ngzhian/d6fffc4a2102aa2e48a293a0b329e187 to your computer and use it in GitHub Desktop.
bash snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read line by line from file | |
while read p; do | |
echo $p | |
done <file | |
# change first letter from upper to lower | |
q="$(tr '[:upper:]' '[:lower:]' <<< ${p:0:1})${p:1}" | |
# sed variable substitution | |
sed "s/$var/r_str/g" file_name >new_file | |
# take note of the double quote, this is a common pattern in bash, double quote allows sub, single doesn't |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment