Cpio all *.txt-files out of folders to just one directory
I need a hint for reading manpage (I did rtfm really) of cpio to do this task as in the headline described. I want to put all files of a certain type, lets say all *.txt files or any other format. Spread in more than hundreds of subdirectories in one directory I would like to select them and just move, copy them all in one directory. As using the following comand it gets me some trouble, may someone could give me a hint.
Thanks in advance!!!
The issue with using cpio is that it preserves the directory hierarchy. You could go with:
but that would generate a process for every file, and cp is not most efficient way to copy files.
Are you trying to just flatten the directory hierarchy? If so, perhaps something like:
which would create hardlinks to all the files in the target directory. Use the -s option of ln if the target directory is in a different filesystem.
If you need to make a copy of the files:
Be advised that nothing is being done for filename collisions.
You also specified find /path/to/folder .*.txt. The -name option is missing, and use single-quotes. Otherwise the shell globbing expansion may give you a surprise.
This User Gave Thanks to derekludwig For This Post:
No. Always use the quotes for every -name or -iname primary operand. (You can get by without it under certain circumstances and with the lack of files matching a pattern in your current working directory; but when you try the same script later after some files have been added or when you run it in a different directory, your script with stop working. Even when the quotes aren't required, adding them will never cause you a problem.)
Hello, this is my first thread here :)
So i have a text file that contains words in each line like
abcd
efgh
ijkl
mnop
and i have 4 txt files, i want to add each line to each file, like file 1 gets abcd at the end; file 2 gets efgh at the end ....
I tried with:
cat test | while read -r... (6 Replies)
Due to budget constraints I have to reinvent an Enterprise backup system in a SPARC (sun4v) Solaris estate (10 & 11). (yep - reinvent wheel, fun but time consuming. Is this wise?! :confused: )
For each filesystem of interest, to try to capture a 'catalog' at the front of each cpio archive (for... (1 Reply)
hi,
i have a requirement to delete all the files from all the directories except some specific directories like archive and log.
for example:
there are following directories such as
A B C D Archive E Log F
which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
wget -x -i link.txt
The above downloads and create unique entries for the 97 links in the text file. However, each new file is saved as CM080 with a FILE extention. Is there a way to convert each file in that directory to a .txt? The 97 files are in... (12 Replies)
How to copy files from one directory to another directory with the subfolders copied.
If i have folder1/sub1/sub2/* it needs to copy files to folder2/sub1/sub2/*.
I do not want to create sub folders in folder2.
Can copy command create them automatically?
I tried cp -a and cp -R but did... (4 Replies)
I have a requirement to delete the files and folders under a given directory.
my directory structure is like this..
Data
|
A(Directory)
|_PDF(Directory)----pdf files
|_XML()Directory --xml files
|--files
|
B(Directory)
|_PDF(Directory)----pdf files
|_XML()Directory --xml files ... (1 Reply)
HI All,
I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing.
now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Hello All. I am trying to do this from a terminal prompt on my mac....
I have 100 folders all named different things. Those 100 folders are inside ~/Desktop/Pictures directory.
Each of the 100 folders are uniquely named. The image files inside of each folder only have some similarities.
... (1 Reply)
I have many types of files (Eg: *.log, *.rpt, *.txt, *.dat) in a directory. I want to display all file types except *.txt.
What is the command to display all files except "*.txt" (9 Replies)