radius
1
i have file 1.txt
asdas|csada|13|03|10|04|23|A1|canberra
sdasd|sfdsf|13|04|26|23|28|A1|sydney
i want to add today's date and time in the end of each row
expected output
asdas|csada|13|03|10|04|23|A1|canberra|130430|1358
sdasd|sfdsf|13|04|26|23|28|A1|sydney|130430|1358
todays date and time is 130430 (30 april 2013) and time is 13:58
tks
try
awk -v var=`date +"|%y%m%d|%H%M"` '{print $0var}' filename
radius
3
big thanks mr vidhya
---------- Post updated at 02:41 AM ---------- Previous update was at 02:40 AM ----------
i have file input
asdas|csada|130310|0423|A1|canberra
sdasd|sfdsf|130426|2328|A1|sydney
Expected output : on eaceh third and fourth colum, split into each two characters
asdas|csada|13|03|10|04|23|A1|canberra
sdasd|sfdsf|13|04|26|23|28|A1|sydney
Below solution is considering your 3rd and 4th column will have same number of character as your example data
sed '/^\([^|]*|[^|]*\)|\(..\)\(..\)\(..\)|\(..\)\(..\)|\(.*\)/\1|\2|\3|\4|\5|\6|\7/g' filename
radius
5
while i run the script, its shown
Unrecognized command: /^\([^|]*|[^|]*\)|\(..\)\(..\)\(..\)|\(..\)\(..\)|\(.*\)/\1|\2|\3|\4|\5|\6|\7/g
Oops sorry missed s
sed 's/^\([^|]*|[^|]*\)|\(..\)\(..\)\(..\)|\(..\)\(..\)|\(.*\)/\1|\2|\3|\4|\5|\6|\7/g' filename
radius
8
if i have file input
asdas|csada|130310|0423|A1|canberra|130430|1358
sdasd|sfdsf|130426|2328|A1|sydney|130430|1358
i expect to substract to column 3 to column 5 and column 4 to column 6 and the sum the result in hours
expected result
asdas|csada|130410|0423|A1|canberra|130430|1358|489
sdasd|sfdsf|130430|1350|A1|sydney|130430|1358|0
---------- Post updated at 03:21 AM ---------- Previous update was at 03:20 AM ----------
489 hours = days between 130410 to 130430 (20 days=480 hours) + hours between 0423 to 1358 (9 hours) = 489 hours
I dont think you have given the right input and expected output files.. Could you please clarify?
radius
10
so sorry hehehe
input
asdas|csada|130410|0423|A1|canberra|130430|1358
sdasd|sfdsf|130430|1350|A1|sydney|130430|1358
output
asdas|csada|130410|0423|A1|canberra|130430|1358|489
sdasd|sfdsf|130430|1350|A1|sydney|130430|1358|0
the dates you are trying to subtract can be from different month and year? If yes it might involve some effort to get the desired output..
radius
12
in this case, yes mr Vidya