generating a list of files with their absolute path in Linux

0 votes

So, I'm writing a shell script that takes file paths as input and hence, I need to generate recursive file listings with full paths. For example, the file bar has the path:

/home/ken/foo/bar

but, as far as I can see, both ls and find only give relative path listings:

./foo/bar   (from the folder ken)

It seems like an obvious requirement, but I can't see anything in the find or ls man pages.

How can I generate a list of files in the shell including their absolute paths?

May 16 in Linux Administration by Shubham
• 13,310 points
41 views

1 answer to this question.

0 votes

If you find an absolute path to start with, it will print absolute paths. Like, if you want to find all .htaccess files in the current directory:

find "$(pwd)" -name .htaccess

or if your shell expands $PWD to the current directory:

find "$PWD" -name .htaccess

find simply prepends the path it was given to a relative path to the file from that path.

answered May 16 by Upasana
• 8,550 points

Related Questions In Linux Administration

0 votes
1 answer

How to find path of software installed in Linux?

There are multiple ways to find the ...READ MORE

answered May 19 in Linux Administration by Rishi
129 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 20 in Linux Administration by DareDev
• 6,810 points
54 views
0 votes
1 answer

How to display a simple list of all disks, like this /dev/sda /dev/sdb ?

You can list all the disk in ...READ MORE

answered Jul 12, 2018 in Linux Administration by DearestOne
• 200 points
113 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
93 views
+5 votes
17 answers

What are job opportunities as a Linux System Administrator?

I just started working professionally as a ...READ MORE

answered Jul 18, 2018 in Career Counselling by eatcodesleeprepeat
• 4,670 points
737 views
0 votes
1 answer

setting a variable output from a bash command

You can use $(command), which in my ...READ MORE

answered Feb 15 in Linux Administration by DareDev
• 6,810 points
90 views
0 votes
1 answer

Linux: Recursive download of a folder via FTP

wget -r ftp://user:pass@server.com/ try this. READ MORE

answered May 30 in Linux Administration by Upasana
• 8,550 points
56 views
0 votes
1 answer

Determining whether a given Linux is 32 bit or 64 bit

try this. getconf LONG_BIT Output: 32, if OS is 32 ...READ MORE

answered May 21 in Linux Administration by Upasana
• 8,550 points
30 views