Thanks Ravi for your help, One thing i wanted to know can you let me know why you care creating the directory for other files apart from fish, because i already have source directory created only for fish file i need to create directory with date folder
And also I think I can your previous code that file successfully copied /not copied / file not present in input directory message in same function
Hello Master_Mind,
That was to make sure in case directory is not present it should create it else it will simply copy it. Let me know if you have any queries on same.
That was to make sure in case directory is not present it should create it else it will simply copy it. Let me know if you have any queries on same.
Thanks,
R. Singh
Thanks ravi and one more thing just wanted to add regarding the echo messages hope I can add in same function. Once again is there a way to achieve in doing in loops instead of going with awk.
And one more thing Ravi, my files in input direcortry has mango_1.txt,apple_1.txt. you code will check exact file name in config file which fail in copying. I need to take if the file name contains like apple* and take the latest file only to copy
I tried something like this
Last edited by Master_Mind; 03-22-2017 at 01:17 AM..
Reason: code tried
As per your request following is in pure shell(uses GNU date too in it). Could you please try following and let me know if this helps you.
Above script's output will be as follows.
So above code will look for all the files with similar names like mango, mango1211.txt, mango1211 etc. Also there are 2 functions in above script named GET_FILE and EXCEPTION_GET_FILE so as per name suggests itself function named EXCEPTION_GET_FILE for files like fish etc. So here is how you need to run them, we need to pass arguments like EXCEPTION_GET_FILE exception_file_name and GET_FILE file_name,it's directory_name another_file_name,it's directory_name and so on. Also for exception files I am not checking similar names, I am exactly checking the same name as exception file name only.
Kindly check it and let me know if this helps you.
NOTE: I placed few test files with similar names into my test directory for testing purposes. Also exception function doesn't have argument of it's directory name so if you need it you could take a look to normal function one and could try to take same method into exception function too.
Thanks,
R. Singh
Last edited by RavinderSingh13; 03-25-2017 at 04:37 PM..
This User Gave Thanks to RavinderSingh13 For This Post:
So I have extremely limited experience with shell scripting and I was hoping someone could point out a few commands I need to use in order to pull this off with a shell script like BASH or whatnot (this is on OS X).
I need to search out for filenames with account numbers in the name itself... (3 Replies)
Hi,
I have several files containing experiment measurements per hour (hour_1.txt has measurements for first hour, etc..etc..). I have 720 of these files (i.e. up to hour_720.txt) and i want to create 720 directories and in every one of them i want to copy its associative file (e.g.... (4 Replies)
I am in a situation where I have some hundreds of thousands of files in a directory (name of directory: big_directory). Now, working on this directory is extremely slow.
I now plan to do this:
Copy 1000 files in each of the directories by creating the directories automatically. All files have... (1 Reply)
Hey guys,
I need to know how to locate all .htaccess files on the server and make a backup of them in the folder they reside before I run a script to modify all of them.
So basically taking dir1/.htaccess and copying it as dir1/.htaccess_bk
dir2/.htaccess copying as dir2/.htaccess_bk... (5 Replies)
Hi to all,
I have the short print out sample of the DOS command "dir S/" as showed below.
Directory of C:\Program Files\Winamp\Skins\Bento\window
02/12/2010 11:35 p.m. <DIR> .
02/12/2010 11:35 p.m. <DIR> ..
11/12/2009 10:31 a.m. 13,556... (3 Replies)
how can i copy those files into other directories have the same name but different in the end
i have files in directory called test:
10_10_asdadfsdfad.txt
10_10_11_asdawqefwkjasd.txt
10_10_11_12_asdafjjhoqwd.txt
i want to put them in exist directory thart i have on my system
i have... (1 Reply)
Hello there, I'm a total noob to shell scripting. :)
What I want to do is compare the contents of Folder A and Folder B, and copy any files in Folder A that do not exist in Folder B over to Folder B.
I have gotten so far as:
diff -rq folderA folderB
which returns the names of the files,... (3 Replies)
Hi guys,
I want to copy folder and sub folders only. I don't want the files. If i use cp -r command it will copy entirely with files.
Could any one suggest me.
Thanks in advance (1 Reply)
I have a report file that is generated every day by a scheduled process.
Each day the file is written to a directory named .../blah_blah/Y07/MM-DD-YY/reportmmddyy.tab
I want to copy all of this reports to a separate directory without having to do it one by one.
However, if I try
cp... (3 Replies)
I have two drives (scsi) mounted on one server and I need to copy certain files and directories from one drive to the other. Any suggestions :confused: (4 Replies)