I'm writing a bash script that will go through all files in /home/someone/directory/. I want to create a list of the files, but make the root /home/someone/directory, (transform /home/someone/directory to /), so the output would look like this:


Here's the same output without any translation:


Is it possible to do this in bash?

1 Answer 1


Use cut:

cut -d'/' -f1,5- infile

select only fields number 1 and 5 to the last

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .