help in inserting values in date format

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help in inserting values in date format
# 1  
Old 02-01-2008
help in inserting values in date format

how to assign values in this date format

a=`date +"%H%M%S"`

how to give value of H=22,here in this format so that i can grep 22nd hour.Below is the script

a=`date +"%H%M%S"`

for i in *.log
cat $i | grep $a | wc -l >> file1.txt

actually wat i m doing is greping Particular hour in all the logs files and storing the count in file1.txt

i want a date format that can be flexible enough to input our own hour values,depending upon my i need that kind of a format to be used in my script.

Last edited by ali560045; 02-01-2008 at 10:29 AM..
# 2  
Old 02-01-2008
Do you mean that you need only the hour field?

date +"%H"

Nagarajan G
# 3  
Old 02-01-2008
I'm guessing that you mean something like the following:

#  date +"%H%M%S"

#  date +"22%M%S"

#  hour=23
#  date +"${hour}%M%S"

Last edited by Tytalus; 02-01-2008 at 10:59 AM.. Reason: minor typo
# 4  
Old 02-04-2008
here is my script
TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d`

b=`date +"23:%M:%S"`

cd /ednadtu3/u01/pipe/logs
for i in Archiver1.log

cat $i | grep $a | grep $b >> /ednadtu3/u01/pipe/naveed/Insert_Date.txt

As this script is outputing the result in Insert_Date.txt but the problem is that file Insert_Date.txt is empty. and i do have results in Acrhiver1.log

2008-02-03 23:10:59,345 [Thread-3] INFO -
2008-02-03 23:40:59,660 [Thread-3] INFO -

not getting why file Insert_Date.txt is empty

Last edited by ali560045; 02-05-2008 at 06:55 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date 19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

2. Shell Programming and Scripting

Inserting values to database

hi , I'm new to Unix shell scripting. I need help to insert read csv which has two columns -emp no and logged date. csv file is a large file so i want to keep the insertion query in a separate .sql file. csv file looks this: empno | loggeddate ___________________ 5666 ,... (5 Replies)
Discussion started by: preema
5 Replies

3. Shell Programming and Scripting

Inserting values into database from an excel

Hi, I have a requirement where I have an excel sheet with the below values COL1 COL2 COL3 Germany URGENT NORMAL I want to cut the values of this excel in such a way that I get the values and pass it to an insert statement update tbfin set... (2 Replies)
Discussion started by: venkidhadha
2 Replies

4. UNIX for Dummies Questions & Answers

Rename all Files in a UNIX Directory from one date format to another date format

Hi Unix Gurus, I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie... (1 Reply)
Discussion started by: pchegoor
1 Replies

5. Shell Programming and Scripting

Problem in inserting values of variable of shell

hi all, i have one shell script like this #!/bin/bash -xv ENV_NAME=`cat $IB_HOME_DIR/cfg/ | grep "RDM_CONN" | cut -f 2 -d "@"` CURRENT_DIR=`pwd`; string=$IB_HOME_DIR string1="$string/FRGFOLDER/input" #sed "s/string3/$string1" frg_event_src.sql > modifiedinsert.sql sqlplus... (2 Replies)
Discussion started by: ramsavi
2 Replies

6. Shell Programming and Scripting

Inserting variable values in filename

Hi All, I have a directory containing multiple files. and also a txt file which contains the list of all filenames and certain values. I want to read the text file line by line and if its 2nd column is matched with the filename in directory, then it must insert the values in 7th column to... (14 Replies)
Discussion started by: CAch
14 Replies

7. Shell Programming and Scripting

modify a file by inserting a conditional values

Hi, input file CCCC 1204 215764.85 9405410.40 1189 DDDD 4498 1503 4617 1507 4723 1517 4829 1528 4996 1540 DDDD 5199 1556 5278 1567 5529 1603 5674 1614 6076 1915 DDDD 6605 2371 7004 2779 CCCC ... (4 Replies)
Discussion started by: Indra2011
4 Replies

8. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

9. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

10. Shell Programming and Scripting

Inserting Values From A File Into A Table

Guys, I want to insert some values from a log file into a temporary table. the values in the log file looks like this SV_NAME CC_NAME CP_DISP_RUN_STATE ------- ------------------- ----------------- sble01 ALLTEL WorkMon24Hrs Running I want to enter the... (2 Replies)
Discussion started by: ragha81
2 Replies
Login or Register to Ask a Question