Monday, February 10, 2014

unix command to remove everything after a character in a string

suppose you want to remove everything in a string after the character  '_'
The command you would use would be:
i=<your string>
j=${i%%_*}


something i have used in the past.
for i in $(ls); do cd ../$i|cut -d '_' -f1; echo pwd; cd ../geo_color/;  done

No comments: