Aysad Kozanoglu - Mimarist

Server Howtos & Tutorials

string cut

30 September, 2017 | Scripts Codes

 

str=abc.out

Shell:

echo ${str%.*}

Grep:

echo $str | grep -o '^[^\.]*'

Sed:

echo $str | sed -E 's/(.*?)\..*/\1/'

Awk:

echo $str | awk -F. '{print $1}'

Cut:

echo $str | cut -d. -f1

output:

abc