Sponsored Content
Top Forums Shell Programming and Scripting Insert text into specific column Post 302747985 by alegnagrp on Monday 24th of December 2012 03:59:23 AM
Old 12-24-2012
Insert text into specific column

I have the following data:

Code:
Dec 24 11:31:10 0000008b 9911662486 Answered Price SGD 0.003 PERIOD: 0 m 6 s
Dec 24 11:21:42 00000086 9911662486 Answered Price SGD 0.001 PERIOD: 0 m 2 s
Dec 20 15:34:28 00000004 9911662486 Answered Price SGD 0.007 PERIOD: 0 m 12 s
Dec 20 18:42:30 0000017b 9911662486 Answered Price SGD 0.005 PERIOD: 0 m 9 s
Dec 20 18:36:04 00000172 9911662486 Answered Price SGD 0.004 PERIOD: 0 m 7 s
Dec 20 18:29:21 0000016d 9911662486 Answered Price SGD 0.007 PERIOD: 0 m 11 s

I would like it to be:


Code:
Dec 24 11:31:10 0000008b 9911662486 Answered Price SGD 0.003 PERIOD: 0 m 6 s
Dec 24 11:21:42 00000086 9911662486 Answered Price SGD 0.001 PERIOD: 0 m 2 s
Dec 20 15:34:28 00000004 9911662486 Answered Price SGD 0.007 PERIOD: 0 m 12 s
Dec 20 18:42:30 0000017b 9911662486 Answered Price SGD 0.005 PERIOD: 0 m 9 s
Dec 20 18:36:04 00000172 9911662486 Answered Price SGD 0.004 PERIOD: 0 m 7 s
Dec 20 18:29:21 0000016d 9911662486 Answered Price SGD 0.007 PERIOD: 0 m 11 s
                                                                                   Total SGD 0.027

The "Total SGD 0.027" is insert into column 7,8,9


Last edited by Scott; 12-24-2012 at 08:37 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

insert text into column

Hello! I have a text file containing some text : : : bla other text : : : bla any text : : : bla containing 3 columns separated by the ':' sign. Now i want to insert 'this' in the 2nd line after the 2nd column-deliminiter (i.e. into 3rd column), like some text : : : bla other text :... (1 Reply)
Discussion started by: knoxo
1 Replies

2. Shell Programming and Scripting

Insert a text from a specific row into a specific column using SED or AWK

Hi, I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it. Here is how the text file looks: _______________________________________________________ DEVICE STATUS INFORMATION FOR LOCATION 1: OPER STATES: Disabled E:Enabled ... (5 Replies)
Discussion started by: Issemael
5 Replies

3. Shell Programming and Scripting

Can sed be used to insert data at specific column?

I'm trying to use sed to insert data at a specific column, let's say my data looks like this: 0553 1828 0552 1829 0550 1829 0549 1830 0548 1831 what I want is this: timein 0553 timeout 1828 timein 0552 timeout 1829 timein 0550 timeout 1829 timein 0549 timeout 1830 timein 0548... (5 Replies)
Discussion started by: mswartz
5 Replies

4. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

5. UNIX for Dummies Questions & Answers

How to insert alternative columns and sort text from first column to second?

Hi Everybody, I am just new to UNIX as well as to this forum. I have a text file with 10,000 coloumns and each coloumn contains values separated by space. I want to separate them into new coloumns..the file is something like this as ad af 1 A as ad af 1 D ... ... 1 and A are in one... (7 Replies)
Discussion started by: Unilearn
7 Replies

6. UNIX for Dummies Questions & Answers

Replacing a specific column of a text file with another column

I have a text file in the following format: 13412 NA06985 0 0 2 46.6432798439 4 4 4 4 13412 NA06991 NA06993 NA06985 2 48.8478948517 4 4 2 4 13412 NA06993 0 0 1 45.8022601455 4 4 2 4 13401 NA06994 0 0 1 48.780669145 4 4 4 4 13401 NA07000 0 0 2 47.7312017846 2 4 4 4 13402 NA07019... (3 Replies)
Discussion started by: evelibertine
3 Replies

7. UNIX for Dummies Questions & Answers

Replacing a specific column of a text file with another column

Hi, I have a text file in the following format: Code: 13412 NA06985 0 0 2 46.6432798439 4 4 4 4 13412 NA06991 NA06993 NA06985 2 48.8478948517 4 4 2 4 13412 NA06993 0 0 1 45.8022601455 4 4 2 4 13401 NA06994 0 0 1 48.780669145 4 4 4 4 13401 NA07000 0 0 2 47.7312017846 2 4 4 4 ... (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

sed - insert text if column empty

Hi, I want to insert the text 'Unknown' in 2 specific columns in a csv file (actually | separated) if the column is blank. Its always the same columns. I have tried using sed: sed "s/||/|Unknown|/g" but there are occasion where other fields are blank and they need to be left blank. This... (4 Replies)
Discussion started by: ksexton
4 Replies

9. Shell Programming and Scripting

Insert text line to specific location CSV

In Perl. ***edited question below*** Hey all, I am teaching myself some simple CSV file manipulation and have become a little stuck. Say I have the following layout in the CSV file: age,name,locationIs it possible to INSERT data into the CSV into the correct age order. For example, if I had... (1 Reply)
Discussion started by: whyte_rhyno
1 Replies

10. Shell Programming and Scripting

Insert space in specific column among many columns

Hello, I have some problem in inserting the space for the pairs of columns. I have the input file : I used this code below in replacing it using space in specific column (replace space in each two columns) sed -e "s/,/ /2" -e "s/,/ /3" inputfile Output showed : However, I have many... (3 Replies)
Discussion started by: awil
3 Replies
cronolog(1m)															      cronolog(1m)

NAME
cronolog - write log messages to log files named according to a template SYNOPSIS
cronolog [OPTION]... template DESCRIPTION
cronolog is a simple program that reads log messages from its input and writes them to a set of output files, the names of which are con- structed using template and the current date and time. The template uses the same format specifiers as the Unix date(1) command (which are the same as the standard C strftime library function). Before writing a message cronolog checks the time to see whether the current log file is still valid and if not it closes the current file, expands the template using the current date and time to generate a new file name, opens the new file (creating missing directories on the path of the new log file as needed unless the program is compiled with -DDONT_CREATE_SUBDIRS) and calculates the time at which the new file will become invalid. cronolog is intended to be used in conjunction with a Web server, such as Apache to split the access log into daily or monthly logs. For example the Apache configuration directives: TransferLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/access.log" ErrorLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/errors.log" would instruct Apache to pipe its access and error log messages into separate copies of cronolog, which would create new log files each day in a directory hierarchy structured by date, i.e. on 31 December 1996 messages would be written to /www/logs/1996/12/31/access.log /www/logs/1996/12/31/errors.log after midnight the files /www/logs/1997/01/01/access.log /www/logs/1997/01/01/errors.log would be used, with the directories 1997, 1997/01 and 1997/01/01 being created if they did not already exist. (Note that prior to version 1.2 Apache did not allow a program to be specified as the argument of the ErrorLog directive.) Options cronolog accepts the following options and arguments: -H NAME --hardlink=NAME maintain a hard link from NAME to the current log file. -S NAME --symlink=NAME -l NAME --link=NAME maintain a symbolic link from NAME to the current log file. -P NAME --prev-simlink=NAME maintain a symbolic link from NAME to the previous log file. Requires that the --symlink option is specified, as cronolog renames the current link to the name specified for the previous link. -h --help print a help message and then exit. -p PERIOD --period=PERIOD specifies the period explicitly as an optional digit string followed by one of units: seconds, minutes, hours, days, weeks or months. The count cannot be greater than the number of units in the next larger unit, i.e. you cannot specify "120 minutes", and for seconds, minutes and hours the count must be a factor of the next higher unit, i.e you can specify 1, 2, 3, 4, 5, 6, 10, 15, 20 or 30 minutes but not say 7 minutes. -d PERIOD --delay=PERIOD specifies the delay from the start of the period before the log file is rolled over. For example specifying (explicitly or implic- itly) a period of 15 minutes and a delay of 5 minutes results in the log files being rotated at five past, twenty past, twentyfive to and ten to each hour. The delay cannot be longer than the period. -o --once-only create single output log from template, which is not rotated. -x FILE --debug=FILE write debug messages to FILE or to the standard error stream if FILE is "-". (See the README file for more details.) -s TIME --start-time=TIME pretend that the starting time is TIME (for debugging purposes). TIME should be something like DD MONTH YYYY HH:MM:SS (the day and month are reversed if the american option is specified). If the seconds are omitted then they are taken as zero and if the hours and minutes are omitted then the time of day is taken as 00:00:00 (i.e. midnight). The day, month and year can be separated by spa- ces, hyphens (-) or solidi (/). -a --american Interprete the date part of the starting time the American way (month then day). -e --european Interprete the date part of the starting time the European way (day then month). This is the default. -v --version print version information and exit. Template format Each character in the template represents a character in the expanded filename, except for date and time format specifiers, which are replaced by their expansion. Format specifiers consist of a `%' followed by one of the following characters: % a literal % character n a new-line character t a horizontal tab character Time fields: H hour (00..23) I hour (01..12) p the locale's AM or PM indicator M minute (00..59) S second (00..61, which allows for leap seconds) X the locale's time representation (e.g.: "15:12:47") Z time zone (e.g. GMT), or nothing if the time zone cannot be determined Date fields: a the locale's abbreviated weekday name (e.g.: Sun..Sat) A the locale's full weekday name (e.g.: Sunday .. Saturday) b the locale's abbreviated month name (e.g.: Jan .. Dec) B the locale's full month name, (e.g.: January .. December) c the locale's date and time (e.g.: "Sun Dec 15 14:12:47 GMT 1996") d day of month (01 .. 31) j day of year (001 .. 366) m month (01 .. 12) U week of the year with Sunday as first day of week (00..53, where week 1 is the week containing the first Sunday of the year) W week of the year with Monday as first day of week (00..53, where week 1 is the week containing the first Monday of the year) w day of week (0 .. 6, where 0 corresponds to Sunday) x locale's date representation (e.g. today in April in Britain: "13/04/97") y year without the century (00 .. 99) Y year with the century (1970 .. 2038) Other specifiers may be available depending on the C library's implementation of the strftime function. SEE ALSO
apache(1m) date(1) strftime(3) environ(5) More information and the latest version of cronolog can be obtained from http://www.ford-mason.co.uk/resources/cronolog/ If you have any suggestions, bug reports, fixes, or enhancements, please mail them to the author. More about Apache Documentation for the Apache http server is available from http://www.apache.org FUTURE DIRECTIONS
The functionality of cronolog could be built into Apache, thus saving the overhead of having a process per log stream and that of transfer- ring data from the server process to the cronolog process. The main complication is handling the case where multiple log streams are writ- ten to the same file (template), for example where different virtual servers write to the same set of log files. AUTHOR
Andrew Ford <A.Ford@ford-mason.co.uk> cronolog is based on a program called rotatelogs by Ben Laurie, which is packaged with the Apache web server. The symbolic link option was suggested by Juergen Lesny. March 1998 cronolog(1m)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy