Monday, 9 September 2013

Split a namefile in shell

Split a namefile in shell

I'm here to know how to split a file name that was found by a ls comand
:D. Let me explain better...
I have a variable
images=$( ls | grep .img )
And then i want to split the result of the search, because i just want the
name before the .img, so a nice idea is use IFS.
IFS=. read -r disk <<< $image
Pretty nice, but when a do an echo with the $disk variable, what i see is
a ".img" just that, i want to recover where is before that dot.
Thank you all, and sorry for any mistake :)

No comments:

Post a Comment