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, 2019 in Linux Administration by Shubham
• 13,450 points
125 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, 2019 by Upasana
• 8,620 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, 2019 in Linux Administration by Rishi
1,906 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, 2019 in Linux Administration by DareDev
• 6,870 points
205 views
0 votes
1 answer

How to check permissions of a file in the Linux system?

Hi@akhtar, If you prefer using the command line, ...READ MORE

answered Aug 13 in Linux Administration by MD
• 78,910 points
147 views
0 votes
1 answer

How to check permissions of a folder in the Linux system?

Hi@akhtar, You can use ls command to check ...READ MORE

answered Aug 13 in Linux Administration by MD
• 78,910 points
133 views
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
220 views
+6 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,750 points
2,875 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, 2019 in Linux Administration by DareDev
• 6,870 points
798 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, 2019 in Linux Administration by Upasana
• 8,620 points
117 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, 2019 in Linux Administration by Upasana
• 8,620 points
65 views