Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cut : use "/" as a delimiter

Tags:

bash

cut

I am trying to use the cut command in my bash script. I need to get the name of a rpm package containing 'sys' in its name, without its full path. So I tried this:

packageName=$(find temp/noarch/ -name '*sys*noarch.rpm' | cut -d "\/" -f 3)

I thought this way could return the package's name without the temp/noarch/, but it only tells me.

I know i could just remove the substring "temp\/noarch\/", but i'd like to make it with cut.

like image 824
Eos Avatar asked Dec 18 '22 05:12

Eos


1 Answers

"\/" doesn't expand to /, so cut complains:

cut: the delimiter must be a single character

Use plain / instead:

packageName=$(find temp/noarch/ -name '*sys*noarch.rpm' | cut -d/ -f3)
like image 145
choroba Avatar answered Dec 20 '22 18:12

choroba