The partial command in question: cut -f-4 -d\"\/\" |sort -u splits the values from the preceding command based on a forward slash /. The backslashes \ are needed because the quotes " and forward slash / are special to the shell and might get interpreted as meaning something rather than just being plain text.
The sort -u is a sort-unique, so having cut off the first 4 fields (null and three layers of directory split by /) there will be duplicates. This ensures that there is only one of each to be assigned to the variable in question.
I'm not sure if that makes it any clearer though. Maybe an example is better. Consider a directory structure like this:-
If the first three layers of directories are significant, you want to get the result like this:-
To do this, my code would first get the first four fields (and delimiters / with the cut command to give you this:-
..... then the sort would reduce it to the required list.
I hope that is a little better.
On the question of finding directories and the '365' file, you might need more steps:
Find all the significant directories as above (storing them in $SRC_CDR_OUTBOUND etc.)
Change your find to a loop for each directory in $SRC_CDR_OUTBOUND:-
Check if the file 365.txt exists with if [ -f $directory/365.txt ] and if it does set the value of days as 365, else 90.
Run the find and mv for the specific directory using the value of days to define the -mtime limit
Go round the loop again for the next directory in $SRC_CDR_OUTBOUND etc.
Does this logic work for you, or have I missed the point?
Please remember to use CODE tags. Simply wrap code and data input/output in CODE tags, like this:-
Quote:
[CODE]This is my code[/CODE]
to produce the following (fixed character width, space respected):-
Not only does it make posts far easier to read, but CODE and ICODE sections respect multiple space and have fixed width characters, which is important for easily seeing input/output requirements.
Last edited by rbatte1; 08-06-2014 at 09:02 AM..
Reason: Correcting LIST formatting
I am in a fix.......
I have to write a backup script to backup say Folder A.
Folder A contains n folders 1,2 ,3 .....n.
my script should copy A without folder 2 & 3.
Is there anyway I can do it without writing individual copy commands????
Please help.... (1 Reply)
I am in a fix.......
I have to write a backup script to backup say Folder A.
Folder A contains n folders 1,2 ,3 .....n.
my script should copy A without folder 2 & 3.
Is there anyway I can do it without writing individual copy commands????
Please help.... (5 Replies)
I have a directory with about 20 folders and many different types of files. I need to search for files and gzip in all the directories except for 1 directory.
How do you exclude a directory? (2 Replies)
I am trying to make a unix shell script that will make 99 folders 99 deep (counting the first level folders). So far i have made it make the first 99 folders and 99 more in all of the folders. The only problem is the only way i have found is copying and pasting part of the script over and over and... (18 Replies)
Hello again,
A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x.
I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
I am familiar with using tar and exclude/include files:
tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion
but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Hi,
Below is the command to grep for a string under
grep -r "redeem" /home/tom
Need to make it case insensitive and exclude logs & tmp folders under /home/tom directory in my Search.
Need this in Linux. (1 Reply)
I have a folder like this
ls input1
dir1 dir2 dir3 file1 file2 file3
dir1, dir2 and dir3 are sub-folders inside the folder input1
ls input2
dir1 dir2 dir3 file1 file2 file3
My dir1 in input1 folder has files f1, f2, f3 and f4.
My dir1 in input2 folder has file f4 and f5.
... (3 Replies)
Hi
Can i archive folder and folders in with the tar command
My files are located in subfolders
Eg: Folder1/Folder1_1/*.pdf
Folder1/Folder1_2/*.pdf
Folder1/Folder1_3/*.pdf
so i would like to tar all the files in Folder1_1 and Folder1_2 only not Folder1_3 that should be done next... (2 Replies)
Hi,
So i know we use cp -r as a basic to copy folders/files.
I would like this BUT i would like to show the output of the files being copied.
With the amazing knowledge i have i have gone as far as this:
1) find source/* -exec cp -r {} target/ \;
2) for ObjectToBeCopied in `find... (6 Replies)