if it helps .. file is received hourly.. in the meantime, I'm countering "syntax error at line 14: `fi' unexpected" -- I must be doing something wrong..
Code:
#!/bin/sh
FILENAME_WANTED=`date +"HourlyDate_%Y%m%d_%H00.txt"`
echo "$FILENAME_WANTED"
FILENAME_CURRENT='HourlyData_20160708_1500.txt'
echo "$FILENAME_CURRENT"
if [ "$FILENAME_WANTED" == "$FILENAME_CURRENT" ]; then
echo "file found"
else
echo "file not found"
fi
A bit strange: "syntax error at line 14" in a 10 line script...? When run with sh, it fails on the == operator. Try with single = only.
And, ...Date... won't match ...Data....
Rodic,
I'm using notepad to write the shell script and invoke it using Putty utility
that is why I was encountering error "syntax error".. some of the echo lines I had embedded "`" symbol .. therefore, those lines seems to be displaying it ok..
So, I tried via "vi editor" from putty prompt and output displayed correctly for file comparison ( "file not found " ) .. but, editing via vi editor was not easy for me..
Qes. here is: can I use "notepad" to write the script and run it using putty interactively.. should I enclose all "echo" with this "`" symbol?
perseus.gasleak(/opt/gsoscada/GSO_SCADA)% ls -t | head -n1
HourlyData_20160713_0700.txt
So, my question was that can I use this syntax in the shell script to pull
latest file and stored in a variable for compassion?
by the way, this is what I see for -
Code:
perseus.gasleak(/tmp/v_tst)% od -bc test.sh
0000000 043 041 057 142 151 156 057 163 150 015 012 106 111 114 105 116
# ! / b i n / s h \r \n F I L E N
0000020 101 115 105 137 127 101 116 124 105 104 075 140 144 141 164 145
A M E _ W A N T E D = ` d a t e
0000040 040 053 042 110 157 165 162 154 171 104 141 164 145 137 045 131
+ " H o u r l y D a t e _ % Y
0000060 045 155 045 144 137 045 110 060 060 056 164 170 164 042 140 015
% m % d _ % H 0 0 . t x t " ` \r
0000100 012 145 143 150 157 040 042 044 106 111 114 105 116 101 115 105
\n e c h o " $ F I L E N A M E
0000120 137 127 101 116 124 105 104 042 015 012 106 111 114 105 116 101
_ W A N T E D " \r \n F I L E N A
0000140 115 105 137 103 125 122 122 105 116 124 075 047 110 157 165 162
M E _ C U R R E N T = ' H o u r
0000160 154 171 104 141 164 141 137 062 060 061 066 060 067 060 070 137
l y D a t a _ 2 0 1 6 0 7 0 8 _
0000200 061 065 060 060 056 164 170 164 047 015 012 145 143 150 157 040
1 5 0 0 . t x t ' \r \n e c h o
0000220 042 044 106 111 114 105 116 101 115 105 137 103 125 122 122 105
" $ F I L E N A M E _ C U R R E
0000240 116 124 042 015 012 151 146 040 133 040 042 044 106 111 114 105
N T " \r \n i f [ " $ F I L E
0000260 116 101 115 105 137 127 101 116 124 105 104 042 040 075 040 042
N A M E _ W A N T E D " = "
0000300 044 106 111 114 105 116 101 115 105 137 103 125 122 122 105 116
$ F I L E N A M E _ C U R R E N
0000320 124 042 040 135 073 040 164 150 145 156 015 012 040 040 040 040
T " ] ; t h e n \r \n
0000340 145 143 150 157 040 042 146 151 154 145 040 146 157 165 156 144
e c h o " f i l e f o u n d
0000360 042 015 012 145 154 163 145 015 012 040 040 040 040 145 143 150
" \r \n e l s e \r \n e c h
0000400 157 040 042 146 151 154 145 040 156 157 164 040 146 157 165 156
o " f i l e n o t f o u n
0000420 144 042 015 012 146 151 015 012 167 150 151 154 145 040 162 145
d " \r \n f i \r \n w h i l e r e
0000440 141 144 040 114 111 116 105 073 015 012 144 157 015 012 040 040
a d L I N E ; \r \n d o \r \n
0000460 145 143 150 157 040 042 044 114 111 116 105 042 015 012 144 157
e c h o " $ L I N E " \r \n d o
0000500 156 145 040
n e
0000503
I have a file , the file content will be modified regularly , its structure as below, the lines are begins with "A" and "B" .
#vi file1
this is testing file
A aaaaa
B bbbbb
A ccccc
B ddddd
A eeeee
B fffff
A ggggg
B hhhhh
I would like to have a script to use the... (3 Replies)
Hi friends, I want to convert 24 hour timing to 12 hour please help me...
my data file looks like this..
13-Nov-2011 13:27:36 15.32044 72.68502
13-Nov-2011 12:08:31 15.31291 72.69807
16-Nov-2011 01:16:54 15.30844 72.74028
15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Hi,
My file
cat a.txt
Sat Nov 27 00:02:00 2010
00:02:00 Usr 27: Login by edi on batch. (452)
00:02:09 Usr 27: Logout by on batch. (453)
00:02:09 Usr 27: Login by edi on batch. (452)
00:02:22 Usr 27: Logout by on batch. (453)
00:02:22 Usr 27: Login by edi on batch.... (3 Replies)
Currently whenever i run date command output is shown like
Mon Apr 12 05:17:21 IST 2010
When its 17:17 Here.
How would i change it so that it should show.
Mon Apr 12 17:17:21 IST 2010 (8 Replies)
I have tried various arguments to get the date display as "Mar 10".
I have tried
date +"%c" -------> Wed Mar 10 11:51:21 EST 2010
date +"%b%d%Y_%H%M%S" --------> Mar102010_115121
date +"%b%d" -------> Mar10
date +"%t%b%e" ... (3 Replies)
Hello People,
How can I display the date in a continuous format along with the time as below :
20091001_154547
i.e yyyymmdd_hhmmss format.
Thanks. (3 Replies)
Hi,
I have some files in a folder with different time stamps and
I want to display the files which are older than 1 hour.
i tried with find.
need urgent help. (7 Replies)
Hi,
I have some files in a folder with different time stamps and
I want to display the files which are older than 1 hour.
i tried with find.
need urgent help. (3 Replies)