script to read number from config file
Hi All,
I've been making some scripts recently and have gotten to the stage where I want to do the following: We have a ftp file setup (call it folder A) and I want to make it so that on a nightly basis the files are moved from folder A to an archive (folder B) then once a week I will Tar the contents of this folder. I have created the following script: Code:
#get the counters id for a new file This is the current method that I have chosen to make the folders unique, Unless there is an option to get the current date and use that in a folder name? Thanks in advance |
Yes. Using the date command in command substitution you can create a folder name with date in any format you want, e.g.
Code:
mkdir $(date +%Y-%m-%d_%H%M) |
Quote:
Is there a way that I can check if the file is empty before continuing? So, in my script i'll create the target folder B but if Folder A is empty it stops? |
There are different ways to check if a folder is empty. Here is an example:
Code:
[[ -z $(ls FolderA) ]] && exit |
Here's another way purely using bash inbuilts
Code:
shopt -s nullglob |
Quote:
Now working perfectly. If anyone would like a copy of my scripts they are below: This moves files from Folder A to Folder B/Today's Date (D-M-Y format) Code:
#!/bin/bash Code:
#change to the scan_archive folder |
Quote:
Kevin Barry |
All times are GMT -5. The time now is 04:03 AM. |