Confirm The Input

In many case, when developing a menu system using shell script, it will be good to prompt the user to confirm that it is okay to run a script.

for example:

Are you sure to run this task? [Yes | No]

Only reply with Yes will continue the action, else the script will exit or return to the menu.

This is useful when executing script that will perform critical tasks, such as rebooting server, stop/start application, purging files, and so on.

How to do that?

Read more »

Popularity: 31% [?]

fgrep files and insert characters before & after the output

I’m preparing a Unix shell script to scan backup log and to check for failure code.

If the directory backup is finished with failure, then the script must be able to pick-up the failed directory and write to an include file for re-submit later.

The backup log should have showing following result:

Backup processing of '/fscm/ldata/91/*' finished without failure.
Backup processing of '/fscm/ldata/92/*' finished without failure.
Backup processing of '/fscm/ldata/93/*' finished without failure.
Backup processing of '/fscm/ldata/94/*' finished without failure.
Backup processing of '/fscm/ldata/95/*' finished without failure.

What if some directories were failed to backup?

Backup processing of '/fscm/ldata/97/*' finished with failure.
Backup processing of '/fscm/ldata/98/*' finished with failure.

Read more »

Popularity: 35% [?]