Quantcast
Browsing all 14 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Shell Script – Delete Old Files

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...

View Article


Image may be NSFW.
Clik here to view.

Shell Script – stat

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 # Delete backup files which are more...

View Article


Image may be NSFW.
Clik here to view.

Shell Script – Check Empty Folder

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. The...

View Article

Image may be NSFW.
Clik here to view.

Shell Script – Check the existence of files which have common file name

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. #!/bin/sh # Read a folder path from user input and check if #...

View Article

Image may be NSFW.
Clik here to view.

Shell Script – Check if a file is updated

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. #!/bin/sh # Update /tmp/test and check whether it is...

View Article


Image may be NSFW.
Clik here to view.

Java – Date validation using SimpleDateFormat

I need to write a program which reads a date string. The program then archives all the data on the server with the input date as an cut off date. The following java program is based on the tutorial in...

View Article

Image may be NSFW.
Clik here to view.

Dialog – Create a Simple Menu for Inexperienced Linux Users

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....

View Article

Image may be NSFW.
Clik here to view.

Maven – Start Jetty Server by Ant task using maven-antrun-plugin

I have the following shell script to start the Jetty Server in my portable web application in Windows. start_jetty.bat start java -DSTOP.PORT=8080 -DSTOP.KEY=stop_jetty -jar start.jar EXIT   It will...

View Article


Image may be NSFW.
Clik here to view.

Mac – Show Hidden Files in Finder

By default Finder would not show hidden files. Use the following commands to change this setting. defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder   If you want to revert the...

View Article


Image may be NSFW.
Clik here to view.

Shell – Redirect output to file with datetime as filename

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   The file is created.   Done =) Reference:...

View Article

Image may be NSFW.
Clik here to view.

Shell Script – Check file owner and other attributes

Here is a simple shell script which would read a user input and return you the owner and group of the input path. check_owner_and_group.sh #!/bin/sh echo "Please enter a file/folder path:" read...

View Article

Image may be NSFW.
Clik here to view.

Jenkins – Get the build user name in job config

I would like to get the username who triggered the Jenkins job in the Post build task. At first i thought the Build User Vars Plugin could work but than i realize those variables are only available in...

View Article

Image may be NSFW.
Clik here to view.

Submit Google Forms by curl command

Google Forms is a very common way to collect user data nowadays. After you have created the form, you could insert it to your web site and present it with your own style. Other than that, we could...

View Article


Image may be NSFW.
Clik here to view.

Shell – String replace

Previously we talked about how to submit a Google Form by the curl command. Submit Google Forms by curl command   In the url, we have to encode the special characters such as whitespace. In shell...

View Article
Browsing all 14 articles
Browse latest View live