This is an example shell script which creates a file with datetime as filename.
eureka.sh
#!/bin/bash echo "Eureka!" > eureka.$(date '+%Y-%m-%d').txt
Done =)
Reference: StackOverflow – linux redirector to log filename with $date variable
This is an example shell script which creates a file with datetime as filename.
eureka.sh
#!/bin/bash echo "Eureka!" > eureka.$(date '+%Y-%m-%d').txt
Done =)
Reference: StackOverflow – linux redirector to log filename with $date variable
Recently, i have a new task which is adding a user account on a Linux box with UI login shell. My project leader suggests a few tools for me to study and finally i pick the the one called pdmenu.
Continue reading
In the housekeeping shell script, i would update some files. The following example will try to update the /tmp/test file and display the result.
Continue reading
Except checking whether the folder is empty or not, i would also like to know whether the *.log files are removed. Here is another example.
Continue reading
I am working on a housekeeping shell script to delete old files and update some files. I want to know whether the .sh is completed without problem. So i made a checking part in the shell script.
Continue reading
Usually, we have to manipulate the file time attributes in the shell script in order to complete the task. Just like the example at Shell Script – Delete Old Files
Continue reading
For housekeeping the backup files on a server, we can write a shell script to remove files which were created some days ago and scheduled it by cron job.
The following code is an example to remove backup files which were created 90 days ago. Please note that the target folder is just the same as the .sh file location and the .sh file is excluded in the command.
Continue reading