shell - Separating string using linux command -
suppose have folder containing files below formats:
hostname.anothername.ouut.ext filename.another.anot.xxx now want separate string inside of first dot , list in file. should linux command? here, hostname inside of first name. output in separate file. output format given below:
hostname filename i able separated words file containing texts hostname.xxxxx.yyyy, filename.xxxx.tttt etc using
cut -d. -f1 <<end hostname.anothername.ouut.ext filename.another.anot.xxx end but hostnae.xxxxx.yyyy, filename.uuuu.xxxxx etc not text here these file containing in folder.
cut simplest solution:
cut -d. -f1 <<end hostname.anothername.ouut.ext filename..another.anot.xxx end hostname filename for file in *; prefix=${file%%.*} echo "$prefix" done
Comments
Post a Comment