UNIX - How to write the NAME & PATH of files from different sub-directories into a single .txt file?
NickName:Eric Hong Ask DateTime:2019-04-03T02:58:44

UNIX - How to write the NAME & PATH of files from different sub-directories into a single .txt file?

So I have a bunch of files in different sub-directories that I want to print the NAME and PATH of these files into a single ".txt" file. This will be a recursive process as the files will be added daily and the ".txt" file will also be updated, so there is no fix amount of files. All the files will be in a ".txt" format.

For example:

C:\Users\jsmith\Desktop\File has folders File1 and File2

File1 contains File1.txt

File2 containts File2.txt

I want the outcome in the ".txt" file to look like:

File1 C:\Users\jsmith\Desktop\File\File1

File2 C:\Users\jsmith\Desktop\File\File2

Can dir /B /S /O > list.txt for UNIX too? That provides the path but what can I do for just the file names?

Copyright Notice:Content Author:「Eric Hong」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55481795/unix-how-to-write-the-name-path-of-files-from-different-sub-directories-into

Answers
user1637056 2019-04-02T19:06:15

To get a recursive list of all the files recursively you can use find .\nTo get both names and full pathes you can try something like:\n\nfind . | while read line ; do echo $line; realpath $line ; done\n",


More about “UNIX - How to write the NAME & PATH of files from different sub-directories into a single .txt file?” related questions

How to handle backslash(\) in filename or folder name. (Qt, Unix)

I am using mac to write platform crossing code. In Unix (including macos), backslash is valid for file name or folder name. In my code, I need to consider QString may be from Windows or Unix. So ...

Show Detail

How to read from and write to a Unix domain socket in Pharo?

my application needs to read and write to a Unix domain socket. How can I do that from Pharo?

Show Detail

how to write unix "time" like utility

I am new to unix and learning to write some c programs that we can execute using gcc compiler in ubuntu. question:I need to write something similar to this: "time ls" where time should be replaced ...

Show Detail

How to configure GNU Emacs to write UNIX or DOS formatted files by default?

I've had these functions in my .emacs.el file for years: (defun dos2unix () "Convert a DOS formatted text buffer to UNIX format" (interactive) (set-buffer-file-coding-system 'undecided-unix ...

Show Detail

Atomic write on an unix socket?

I'm trying to choose between pipes and unix sockets for an IPC mechanism. Both support the select() and epoll() functions which is great. Now, pipes have a 4kB (as of today) "atomic" write, which is

Show Detail

How to write Unix end of line characters in Windows?

How can I write to files using Python (on Windows) and use the Unix end of line character? e.g. When doing: f = open('file.txt', 'w') f.write('hello\n') f.close() Python automatically replaces \n

Show Detail

How to write Unix end of line characters in Windows?

How can I write to files using Python (on Windows) and use the Unix end of line character? e.g. When doing: f = open('file.txt', 'w') f.write('hello\n') f.close() Python automatically replaces \n

Show Detail

How write the ignore dupkey command in unix?

I know that in oracle the is a way to write to ignore the dupkey, something like /*+ ignore_row_on_dupkey_index(tab, index_tab) */ Is there a way to do the same thing but with unix commands? I th...

Show Detail

How to write DOS line endings to a file from Unix

My Unix Ruby program needs to write a file that will be read by SqlServer running on Windows. I need for the lines I write to this file to end in \r\n, the DOS/Windows line ending, rather than \n,...

Show Detail

How to write autorun programm in unix shell

I am a newbie in unix shell. I want to write a script which would be create an autorun script , and when if some conditions hold true autorun will run. So i don't know what should i write in auto...

Show Detail