|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can anyone offer a good way to cut up a logfile that is laid out vertically? As in:
username datetime *********** username datetime *********** So I need to grab the username and datetime lines only - and cat them into the same line so I can parse them into a db - Any thoughts appreciated - eb - |
|
#2
|
||||
|
||||
|
Is there any obvious commonaility with the lines you wish to be extracted?
Is it: username datetime username datetime that you wish, i.e., a username followed by the next datetime? Does the ******** denote unwanted output? If so, is it a fixed amount of lines, or variable?
__________________
According to Sod's Law, buttered toast lands butter side down, when dropped. Per nature, cats always land on their feet. So, what happens when you strap buttered toast to the back of a cat and throw it out a window?. |
|
#3
|
|||
|
|||
|
Code:
grep -v -e '^$' -e '\*\*' filename| awk '{ printf("%s\t",$0);
getline; print $0}' > newfile
the "%s\t" makes the output file tab delimited, you can change it to another character. Last edited by jim mcnamara : July 18th, 2006 at 02:02 PM. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Text File Manipulation 2 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|