print all filenames in directory with path to another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting print all filenames in directory with path to another file
# 1  
Old 06-07-2012
print all filenames in directory with path to another file

hi,


i have a directory at
Code:
/path/unix

with the following files

Code:
1.txt
2.txt
3.txt
4.txt

I want to make another file called
Code:
filenames.txt

at a different location called /path/home. So, my output file would be

Code:
/path/home/filenames.txt

with contents

Code:
/path/unix/1.txt
/path/unix/2.txt
/path/unix/3.txt
/path/unix/4.txt

I tried the following code

Code:
ls -d $PWD/* > /path/home/filenames.txt

It is giving me an error saying

Code:
-bash : /bin/ls: Argument list too long

# 2  
Old 06-07-2012
Try..
Code:
find /path/unix -type f >  /path/home/filenames.txt

This User Gave Thanks to clx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

2. UNIX for Advanced & Expert Users

A way to print only part of directory path

Hi, So I struggled to find a solution to the following problem: I want to make sed print only part of multiple different paths. So lets say we have /path/path1/path2/logs/bla/blabla /path/path1/path2/path3/logs/yadda/yadda/yadda Can someone suggest a way to make sed or other... (5 Replies)
Discussion started by: dampio
5 Replies

3. Shell Programming and Scripting

There are multiple filenames in the directory.How to return the the lastest files for each file name

there are mutiple file nams in the directory. How to return the the lastest files for each file name. ex. abc1234_050201 abc1234_050206 abc1234_050208 xyz34_050204 xyz34_050210 xyz34_050218 thanks (4 Replies)
Discussion started by: grand_sam
4 Replies

4. Shell Programming and Scripting

How to take the filenames from a directory and store into a file??

hi, how can i take the file names from a directory and store only the filenames in the file. suppose i have a directory which contains the following files and subdirectories. $ ls -ltr total 16 -rw-rw-r-- 1 adm etc 4 Aug 6 20:37 s1.txt -rw-rw-r-- 1 adm etc 4 Aug 6 20:37 s2.txt... (11 Replies)
Discussion started by: Little
11 Replies

5. Shell Programming and Scripting

How to get filenames in a directory and write them in to a file?

I need to get the names of files which are starting with a string testfile. Also i want to create a XML file in the same location and write these file names into the XML. Ex: <path> <dir> <file>testfile1</file> </dir> <dir> <file>testfile2</file> </dir>... (4 Replies)
Discussion started by: vel4ever
4 Replies

6. Shell Programming and Scripting

[awk] print all filenames in directory

Hello, I was given a (I suppose) a simple task which I don't know how to do. Before coming here I have read a dozen of awk tutorials (full read, not just line-skipping) but I still don't know how to do this. Task: Write an script file 'check.awk' with a parameter current directory that... (5 Replies)
Discussion started by: c0dehunter
5 Replies

7. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

8. Shell Programming and Scripting

Print directory name along with their path

Can any one tell me that how can i print all directory with their path in a given parent directory. i.e. parent directory /home/usr/ Now this shoe directory may contain sevral directory /home/usr dir1/ dir1.1/ dir1.2/ dir2 dir2.1/ dir2.2/ ... (5 Replies)
Discussion started by: jadoo_c2
5 Replies

9. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

10. Shell Programming and Scripting

Replacing string in all instances (both filenames and file contents) in a directory

Hi, I have a set of files stored in a single directory that I use to set parameters for a physics code, and I would like to streamline the process of updating them all when I change a parameter. For instance, if the files are called A2000p300ini, A2000p300sub, A2000p300run, and the text in each... (3 Replies)
Discussion started by: BlueChris
3 Replies
Login or Register to Ask a Question