The below program will read all the first character of a line and join it together.
#!/bin/bash F="file.txt" for i in $(cat $F) do echo $i | awk -F"_" 'BEGIN{ st="" } { for( i=1; i<=NF; i++ ) { st=st""toupper(substr($i,1,1)) } } END{ print st }' done
The program will read a file with "_"(underscore) delimited content. Then all the first character of the line will be striped and joined together.
Eg:
File name : Word_File_Created_by_John"
Output : WFCBJ
Note then small case is also turned to upper case.
The below awk functions are used in this program
toupper() - This will convert the string to upper case
substr() - This will strip the specific character(s) from the string
Comments
Post a Comment