Hi ,I got one data file from external source and I have to load it in database through sql loader. I want to add 2 columns in database,one is file name and one is time of the file received on server.
-rwxr-x--- 1 user user 238 Jun 03 16:32 90936264971326030616.ctr
From above case, I want one field as 'Jun 03 16:32' and one as "90936264971326030616" (file name without extension).
Quite sparse a request, no? What tools would be preferred? What would the data be used for, and how? How or where to store the data? In a file? In stdout (to be piped into sth.)? In shell variables?
The actual requirement I have is to take the timestamp (file name here can be ignored), append it to all rows in the file so that it can loaded in database through sqlldr.
Once I extract the timestamp of the file in UNIX and pass it in one variable like $1 then I can further use the below command to make a new data file which I will load.
sed -e 's/$/ May 04 09:02/' summary_file.sql > Data_file.sql
I hope I am clear now.
I tried your suggested command :
File content is:-
***************
-rw-r----- 1 owner owner 976 May 04 09:02 summary_file.sql
I want some help once again. I tried many commands for picking the system timestamp for a particular file.
by
ls -l
, i am only getting date and time but not year, so this command is not fulfilling my requirement
ls -l 79396246719284800001_WBR_REPORT_PROCESS_STATUS_1467192848.mdata | awk '{print $6,$7,$8}'
Jun 29 09:43
I want the date with current year also and final out put is required in following format
29/06/2016 09:43:00
.
Stat is not working in unix .I tried istat ,it gives me very elaborated output , through which I grep only last modified line and found below output :-
Thanks for all your help..I am done with everything else..one last help required is with sed command. When i am using this command in shell script
I used a variable vfile2 to define some value
when I try to print in my logs, i am getting the value of this variable correctly.
But when I try to use it in sed command then it appends ${v_File2} in the file,instead of its value.