Hello DaniWeb / Linux Users and Programmers,

I am 90% new to the world of Linux.

I was instructed to edit a running program.

The purpose of editing this program was to follow the format of the other running program.

But it is hard for me to understand because some of the codes have like this:

-u , -d , +%-H , -ud , $1 , etc...

So I look on the internet but it show the basic commands not the exact meaning for the given example.

anyone can tell me the meaning for it?

for fast track... and also I was focusing first on Time...

You can edit a running bash script, but it will probably crash, or you will have to restart it in any case. In any case, post the original code, and yours here for better comments and feedback.

When you edit a text file, such as a bash script, the changes go into the same physical file (determined by the file's inode). If you want to change it, but not impact the running program, then copy it, edit the copy, and then copy back to the original file name. That will have a new inode and the running program will continue to use the original script until you restart it. At that point, the old one goes away (the inode is freed) and the new one becomes the script that the system sees.

This is how Linux can update programs and shared libraries without restarting the system and programs in question.

Hello Sir Rubberman,

I create my own file so I won't affect any file in the Crontab.

Correct me if I'm wrong, Crontab is something like a setting a schedule?

My boss said that I can insert my file to Crontab but that will be the last part to do I think.

So I focus now on the Time initialization.

I'm afraid I don't know how to copy paste code because I run my Ubuntu in a VMware.

and I really don't know also how to copy paste in terminal. (Sorry I used Microsoft from my entire life)

So going back.. I access the other Computer (Linux Base) where the running program was there.

Just using the Vim command to rewrite the code.

I try re-type the code where the time and date are related:

So this one is the format to be followed.

#!/bin/bash

function fc_date {
           hh=`printf "%02d" $1`
           FDATE=`date -d ""$YMD" +"$HH" hours +"$hh" hours + 8 hours" +"%a %d-%b-%Y %I%p"1
}

function date-near3 {
            if [ -z $1 ];
            then
                               chr=`date -u +%-H`
                               rhr=$(( chr%3 ))
                               YMDH=`date -u -d "now - $rhr hours" +%Y%m%d%H`
             elif [[ $1 == *[!0-9]* ]];
             then
                                echo "$1 is not a valid input. Format should be YYYYMMDDHH"
                                exit 1
             elif [[ $1 -le 2012110100 || ${1:8:2}%3 -ne 0 || $1 -ge 202012311 ]];
             then
                                echo "$1 is not a valid input. Format should be YYYYMMDDHH"
                                exit 1
             else
                                YMDH=$1
             fi
}

function date_chop {
              YMDH=$1
              YYYY=${1:0:4}
              MM=${1:4:2}
              DD=${1:6:2}
              HH=${1:8:2}
              YMD=${1:0:8)
}

So this code was one of the code that I was still studying.

The thing is some of the codes is a very big question for me.

-u +%-H is one that I don't understand. Other line have -d

Any explanation to this shortcut commands?

And some line have ${1:8:2}%3

I do understand the -le -ne -ge stands for less equal not equal greater equal

how about the -u -d and other.. I can't find it through google that is why it is hard for me to understand.

Please have some explanation.

Try by reading the manual of the date command. Type

man date

in a terminal. Read the section about the output format. On my computer, typing

date -u +%-H

currently prints the number 7. Try to understand why.

Also to copy and paste in a bash terminal, you can use Ctrl-Shift-c and Ctrl-Shift-v

Hello Sir Gribouillis,

Thank you for your help sir. That add me knowledge.

I only see my co-worker using the mouse ball to copy and paste but I still don't know the trick on that.

Ctrl+Shift+C / V now it is easy for me to copy & paste :)

I be seeing the Date Command Linux in google. Thank you again Sir.

Will update for the next Question that encounter.

Some commands like "-vp" "-rf" "grep '^-' " and many more that haven't seen commands.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.