Remove text with sed or anything?

Hi there, my first post, so you might find my noobness :wink:

I need help to fix a thing,

find /mnt/fs01/gfx/ -iname "*.rar" > gfx.txt

Gives this contained textfile:

/mnt/fs01/gfx/toba/toba.rar
/mnt/fs01/gfx/zeta/zimba.rar
/mnt/fs01/gfx/brashe/getha.rar

And now the tricky part (for me as well) comes, I want to edit the file to remove everything behind the last "/", so it isn't point out the rar-file itself, and replace it with " 1" like:

/mnt/fs01/gfx/toba/ 1
/mnt/fs01/gfx/zeta/ 1 
/mnt/fs01/gfx/brashe/ 1

The thing is that I will call another script and loop through this one, and this script needs the path and a "1" behind the path.

Anyone have an idea how to solve this?

Regards

Remove every non-/ character from the end and replace by space-one:

sed 's#[^/]*$# 1#'

A variant ensures there is a / before the non-/ characters:

sed 's#/[^/]*$#/ 1#'

Hi,
If you use "find gnu version", you can do this:
my tree example:

dirtest/dir1/dir11/dir111/iii.rar
dirtest/dir2/dir21/xxx.rar
dirtest/dir3/dir31/dir311/yyy.rar

command find:

$ find dirtest -iname "*.rar" -printf "%h/ 1\n"
dirtest/dir1/dir11/dir111/ 1
dirtest/dir2/dir21/ 1
dirtest/dir3/dir31/dir311/ 1

Regards.

Thanks, works like a charm!