0

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:

/file1
/file2
/dir1
/dir1/file1

Here's the same output without any translation:

/home/someone/directory/file1
/home/someone/directory/file2
/home/someone/directory/dir1
/home/someone/directory/dir1/file1

Is it possible to do this in bash?

1 Answer 1

0

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 .