how do you know the 1500 directories. That is the "list_of_dir"
I agree with methyl, your code looks like someone who can program but does not know shell. FORTRAN comes to mind.
Assume the directories you want to mess with are under two main directories. Assume they are /data1 /old_data1. you have many and we will assume those directories lie in a series of subdirectories under the two main ones. I will show you to expand them.
file name matching (expansion) looks like this to find sub directories /directory/*.
This gets everything, all files, including directories
This gets JUST directories, ~/ is shorthand in bash for your login directory.
Now you have a list of directories. Assuming you think your code works correctly
I added the code in red. Change the find command to include your directories.
If you already have a list, use that instead.
Just like in other languages, indentation helps readability....
Also modify whatever script created those directory atrocities to start with. Why? UNIX filesystems have limits to the length of filenames and they have length limits to the entire path: [/directorynames..../.../../../../,../loooongfilename]. If you can show us the output of
Also a caveat - lots of directories using lots of files use LOTS and LOTS of inodes. Each entry in a directory plus the directory name use an inode. You hit the limit you can't do much with the disk.... You run out of them, you lose. You have to be proactive. Really large directory files are a bad sign.
will show you how large a directory is. When you have directories in the MB range it is time to think about it long and hard.
Last edited by jim mcnamara; 08-24-2012 at 11:34 PM..
This User Gave Thanks to jim mcnamara For This Post:
Please help - I need to copy a single file to multiple directories.
Dir structure:
Parent_Directoy
Filename1
Child_Directory1
Child_Directory2
Child_Directory3
Child_Directory4
....
So I need to copy Filename1 to all of the... (2 Replies)
I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions , to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like... (5 Replies)
Hi ,
I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory.
how to write this in a simple script, I have made my code complex
if ; then
taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Hi,
Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly.
I have directories (eg 40001, 40002, etc) that each have one subdirectory (01).
Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir.
I need to keep the top and... (7 Replies)
Hi All Genious,
I want to copy a file name XYZ .In a directory /HOME/dir/IXOS1/dir1
which contain multiple directories named not in pattern want to copy the XYZ in all of the directories available on path /HOME/dir/IXOS1/dir1 .
Thanks in advance . (2 Replies)
Hello
I'm making script for Dallas temperature sensors (DS1820).
When a sensor is connected, it shows up as a directory in /sys/bus/w1/devices
in format 10-xxxxxxx. Inside the directory is a file called w1_slave which holds the temperature in format t=xxxxx.
Each sensor has unique... (2 Replies)
Hi,
Need help ...I want to create multiple directories in different /file systems using for loop..eg.../ORCL_data01/oradata/orcl/ctl.
../ORCL_data01/oradata/orcl/data.
../ORCL_data01/oradata/orcl/redo.
Script :-
=========
for dir in `ls -d... (8 Replies)
Hi,
Can someone please help me with a Command to Search a FILE for a STRING in multiple DIRECTORIES.
I am searching for the VIP in HTTPD.CONF in multiple httpd instances.
I am using
find ./ -name "httpd.conf" | xargs grep 10.22.0.141 cut -d: -f3- | cut -d ' ' -f4 | sort | uniq -c
... (1 Reply)
I am trying to merge or combine all $1 values in validation.txt from multiple directories into one new file and output it here tab-delimited:/home/cmccabe/Desktop/20x/total/total.txt. Each $2 value and the header would then be a new field in total.txt. I am not sure how to go about this as cat is... (2 Replies)