Sponsored Content
Top Forums Shell Programming and Scripting parse of lines with different delimiters Post 302195997 by alamitab on Friday 16th of May 2008 11:26:46 AM
Old 05-16-2008
Is not the nicer solution, but you can try:

Code:
#! /usr/bin/ksh
#set -x
touch file_1
touch file_2
touch large
touch final
if [ -f large ]
then
cat /dev/null > final
fi
if [ -f final ]
then
cat /dev/null > final
fi
cat /dev/null > file_1
cat /dev/null > file_2
while read line
do
        echo $line | grep subject >> file_1
        echo $line | grep message >> file_2
done < $1
paste file_2 file_1 > large
while read line
do
SUB=$(echo $line | awk -F"." '{print $5}')
SD=$(echo $line | cut -b13-22 | sed 's/:/-/g')
SP=$(echo $line | cut -b40)
TS=$(echo $line |cut -b84-99 | sed 's/:/-/' | sed 's/:/-/')
VP=$(echo $line |cut -b112-114)
echo "$SD,$SUB,$TS,$SP,$VP" >> final
done < large
rm large file_1 file_2


_________

- execution ./script file_name
- the result is the file final
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert lines between delimiters

I'm working with a file like: somestuff somemorestuff ... someadditionalstuff STARTTAG ENDTAG someotherstuff somecoolstuff ... somefinalstuffI've got some text (either in a file or piped) to put between STARTTAG and ENDTAG. I was thinking something like grepping for the line number of... (2 Replies)
Discussion started by: BMDan
2 Replies

2. Shell Programming and Scripting

Parse and count lines

I have a data file in the following format (refer to input file) with multiple lines containing some information. I need an output file to loop thorough the input file with summarized information as seen below (refer to output file) ‘Date Time' and ‘Beta Id' input file values should be concatenated... (7 Replies)
Discussion started by: shekharaj
7 Replies

3. Shell Programming and Scripting

commenting out lines between two delimiters

Hi All, I am struggling to get my head around the following issue. I am having to comment out lines between two delimiters by placing an asterix in position 7 but retain all lines in the file and in the same order. so for example a file containing: ... ... DELIM1 ... ... DELIM2... (2 Replies)
Discussion started by: Bruble
2 Replies

4. Shell Programming and Scripting

Parse out specific lines

Hello, For the life of me, I can't figure out how to extract only certain lines of a file. For example, the file contains: project.max-sem-ids privileged 1.02K - deny - system 16.8M max deny ... (2 Replies)
Discussion started by: PointyWombat
2 Replies

5. UNIX for Dummies Questions & Answers

How to parse 2 particular lines from Command output

Hi All, I need help on the following req. I am getting output of a command as follows: 16377612 total memory 3802460 used memory 2827076 active memory 681948 inactive memory 12575152 free memory 477452 buffer memory I want to compute used... (1 Reply)
Discussion started by: mailsara
1 Replies

6. Shell Programming and Scripting

How to parse a numeric string without any delimiters?

Hi , I have a number say 12345001 which needs to be parsed. Its a number that has no delimiters.I have to read the last three digits and then the rest of digits irrespective of the total length of the number. The digits then have to be swapped and changed to a fixed length. The fillers to be... (10 Replies)
Discussion started by: Sheel
10 Replies

7. Shell Programming and Scripting

parse lines

I have file which is having 500 lines. I want to get the first 100 lines then sleep, then again next 100 lines sleep so now till the end of the file. Can someone tell me in perl and bash. also i want to do it in threads. Thanks.. (6 Replies)
Discussion started by: Anjan1
6 Replies

8. Shell Programming and Scripting

Concatinating the lines based on number of delimiters

Hi, I have a problem to concatenate the lines based on number of delimiters (if the delimiter count is 9 then concatenate all the fields & remove the new line char bw delimiters and then write the following data into second line) in a file. my input file content is Title| ID| Owner|... (4 Replies)
Discussion started by: bi.infa
4 Replies

9. Shell Programming and Scripting

awk: Print fields between two delimiters on separate lines and send to variables

I have email headers that look like the following. In the end I would like to accomplish sending each email address to its own variable, such as: user1@domain.com='user1@domain.com' user2@domain.com='user2@domain.com' user3@domain.com='user3@domain.com' etc... I know the sed to get rid of... (11 Replies)
Discussion started by: tay9000
11 Replies

10. Shell Programming and Scripting

Grep lines only with 3 delimiters

Hi All, my file has following Data 04:38:34 02:03 24:40 02:09:58 09:13 03:04:11 02:09:58 35:00 I want to display only lines with 3 fields. ie.. 04:38:34 02:09:58 03:04:11 (6 Replies)
Discussion started by: Arunselvan
6 Replies
touch(3NCURSES) 														   touch(3NCURSES)

NAME
touchwin, touchline, untouchwin, wtouchln, is_linetouched, is_wintouched - curses refresh control routines SYNOPSIS
#include <curses.h> int touchwin(WINDOW *win); int touchline(WINDOW *win, int start, int count); int untouchwin(WINDOW *win); int wtouchln(WINDOW *win, int y, int n, int changed); bool is_linetouched(WINDOW *win, int line); bool is_wintouched(WINDOW *win); DESCRIPTION
The touchwin and touchline routines throw away all optimization information about which parts of the window have been touched, by pretend- ing that the entire window has been drawn on. This is sometimes necessary when using overlapping windows, since a change to one window af- fects the other window, but the records of which lines have been changed in the other window do not reflect the change. The routine touch- line only pretends that count lines have been changed, beginning with line start. The untouchwin routine marks all lines in the window as unchanged since the last call to wrefresh. The wtouchln routine makes n lines in the window, starting at line y, look as if they have (changed=1) or have not (changed=0) been changed since the last call to wrefresh. The is_linetouched and is_wintouched routines return TRUE if the specified line/window was modified since the last call to wrefresh; other- wise they return FALSE. In addition, is_linetouched returns ERR if line is not valid for the given window. RETURN VALUE
All routines return the integer ERR upon failure and an integer value other than ERR upon successful completion, unless otherwise noted in the preceding routine descriptions. X/Open does not define any error conditions. In this implementation is_linetouched returns an error if the window pointer is null, or if the line number is outside the window. Note that ERR is distinct from TRUE and FALSE, which are the normal return values of this function. wtouchln returns an error if the window pointer is null, or if the line number is outside the window. PORTABILITY
The XSI Curses standard, Issue 4 describes these functions. Some historic curses implementations had, as an undocumented feature, the ability to do the equivalent of clearok(..., 1) by saying touch- win(stdscr) or clear(stdscr). This will not work under ncurses. NOTES
Note that all routines except wtouchln may be macros. SEE ALSO
ncurses(3NCURSES), refresh(3NCURSES). touch(3NCURSES)
All times are GMT -4. The time now is 02:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy