Created
October 9, 2015 07:16
-
-
Save NiharG15/f5d1a4a7b278ba0f0fa5 to your computer and use it in GitHub Desktop.
A shell script to capitalize first and last characters of every word in given file
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
#!/bin/bash | |
#This script capitalizes the first and last letters of each word in infile and writes the output to outfile | |
#This regex matches first character of every word which is converted to uppercase by \u\1 | |
sed -e 's/\b\(.\)/\u\1/g' infile > tmpfile | |
#This regex matches last character of every word which is converted to uppercase by \u\1 | |
sed -e 's/\(.\)\b/\u\1/g' tmpfile > outfile | |
#Delete temporary file | |
rm tmpfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment