Read data from one file and putting in new file ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read data from one file and putting in new file ??
# 15  
Old 12-05-2008
Thanks Franklin52 for your Great HELP, now code is working with my file.

Can you please check the thread named below in Shell Programming and Scripting, Actually i having problem in that too, actually i want command output in new fie but complete output is not coming in output file.

Please check this thread and help if you can.

Getting command output and putting into newfile

Regards,
Waqas Ahmed
# 16  
Old 12-06-2008
Hello All,

Code:
nawk '/CELL/{sub(",","",$2);$1=$1;print > tolower($1$2)}' file > newfile

INPUT FILE
KarachiOMP root> cat all
OP:ALARM,ALL!
 PF

M 54 OP:ALARM
     CELL 3 PACKET PIPE (PP) 3
     CELL 3, CDM 1 CBR 3 TRANSMIT PORT (TXPORT) 1

     CELL 4 PACKET PIPE (PP) 1

     CELL 5, CDM 1 ANTENNA DIVERSITY IMBALANCE 3
     CELL 5 RECEIVE AMPLIFIER FAILURE 4
     CELL 5 RECEIVE AMPLIFIER FAILURE 6

     CELL 6 RECEIVE AMPLIFIER FAILURE 2

     CELL 7, CDM 1 CBR 2 TRANSMIT PORT (TXPORT) 1

     CELL 10, CDM 1 ANTENNA DIVERSITY IMBALANCE 3
     CELL 10 RECEIVE AMPLIFIER FAILURE 5

I have one more question as the above code creates multiple files according to cell * numbers.

What if i have the same data (as input file) merge with many other lines in the log file and i want to just get those line which start from word CELL and then put all the data in single file. and when the word cell 86 comes so the script stops and output file creates containing same data as input file from cell 1 to cell 85

Regards,
Waqas Ahmed
# 17  
Old 12-06-2008
Code:
nawk '/CELL 86/{exit}/CELL/{$1=$1;print}' file > newfile

Regards
# 18  
Old 12-06-2008
Code:
nawk '/CELL 86/{exit}/CELL/{$1=$1;print}' LOG > newfile

Above code is also getting other unwanted lines from LOG file. I just want those files which start from word CELL like this:
Code:
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 5
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 7
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 8
CELL 83 RECEIVE AMPLIFIER INDETERMINATE 1

But above code is also getting lines like this:
A 46 REPT:CELL 65 CP FAILURE, UNANSWERED ORIGINATION
A 46 REPT:CELL 35 CP FAILURE, ANSWERED TERMINATION
A 46 REPT:CELL 7 CP FAILURE, UNANSWERED ORIGINATION

Actually i want to tell you the exact story what i am try to do, one other thread is also going on that issue so please dont consider it duplicate thread issue.

i am running below code:
Code:
/omp/bin/TICLI "op:alarm,all" &
nawk '/CELL 86/{exit}/CELL/{$1=$1;print}' /omp/omp-data/logs/OMPROP1/081207.APX > all

what my requirement is get complete output of this command:
/omp/bin/TICLI "op:alarm,all"

in output file, but when i run this:
/omp/bin/TICLI "op:alarm,all" > outputfile
so always different amount of data comes in my file but never complete.

when i run that command so the output of the command is also generated in our LOG file so now i am trying to extract the output of that command through log file.

But because log file contains data of whole system and many other commands so i need some mechanism that at the same time i run command on the shell and the output of sametime comes in output file.

Regards
Regards,
Waqas Ahmed
# 19  
Old 12-06-2008
Quote:
Originally Posted by wakhan
Code:
nawk '/CELL 86/{exit}/CELL/{$1=$1;print}' LOG > newfile

Above code is also getting other unwanted lines from LOG file. I just want those files which start from word CELL like this:
Code:
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 5
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 7
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 8
CELL 83 RECEIVE AMPLIFIER INDETERMINATE 1

But above code is also getting lines like this:
A 46 REPT:CELL 65 CP FAILURE, UNANSWERED ORIGINATION
A 46 REPT:CELL 35 CP FAILURE, ANSWERED TERMINATION
A 46 REPT:CELL 7 CP FAILURE, UNANSWERED ORIGINATION
Try this:

Code:
nawk '{$1=$1}/^CELL 6/{exit}/^CELL/' LOG > newfile

# 20  
Old 12-07-2008
No this code is not giving any output in output file.

Code:
/omp/bin/TICLI "op:alarm,all" &
nawk '{$1=$1}/^CELL 6/{exit}/^CELL/' /omp/omp-data/logs/OMPROP1/081208.APX > all

Below code is giving output in output file but it is also getting other unwanted lines from LOG file.
Code:
/omp/bin/TICLI "op:alarm,all" &
nawk '/CELL 86/{exit}/CELL/{$1=$1;print}' /omp/omp-data/logs/OMPROP1/081208.APX > all

I just want those files which start from word CELL like this:
Code:

CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 5
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 7
CELL 83, ASMB 1 TRANSMITTER AMP INDETERMINATE 8
CELL 83 RECEIVE AMPLIFIER INDETERMINATE 1


But above code is also getting lines like this:

A 46 REPT:CELL 65 CP FAILURE, UNANSWERED ORIGINATION
A 46 REPT:CELL 35 CP FAILURE, ANSWERED TERMINATION
A 46 REPT:CELL 7 CP FAILURE, UNANSWERED ORIGINATION

Regards,
Waqas Ahmed
# 21  
Old 12-08-2008
Post the a portion of /omp/omp-data/logs/OMPROP1/081207.APX.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

2. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

3. UNIX for Dummies Questions & Answers

How to read data from zip file?

Hi All, could you please answer the below question. 1)How to read the data from zip file without unzip? Regards Priyanka (2 Replies)
Discussion started by: pspriyanka
2 Replies

4. Shell Programming and Scripting

Read file data and send to different file

junk.txt has a single numerical value in it, let's say 50421.44. over.namelist has lots of expressions in it, but somewhere random it says value = x.x I need to go into junk.txt, pull out the number, and amend over.namelist to say value = 50421.44. :(:( I'm trying to use sed, but... (5 Replies)
Discussion started by: jammyjames
5 Replies

5. Shell Programming and Scripting

Want to read data from a file name.txt and search it in another file and then matching...

Hi Frnds... I have an input file name.txt and another file named as source.. name.txt is having only one column and source is having around 25 columns...i need to read from name.txt line by line and search it in source file and then save the result in results file.. I have a rough idea about the... (15 Replies)
Discussion started by: ektubbe
15 Replies

6. Shell Programming and Scripting

Read the apecific data from one file and write into another file

Hi, I would like to read the specific data from file and write the data in the new file. My data input is something like this.. <EXROP:R=TJ0311T; ROUTE DATA R ROUTE PARAMETERS TJ0311T DETY=UPDR TTRANS=1 FNC=3 MA=628160955000 R=TJ0311D ... (3 Replies)
Discussion started by: bha148
3 Replies

7. Shell Programming and Scripting

Read data in XML file

Hello Everybody, I have a question on reading the data from XML file through KSH shell script. In the below file I need to collect the patient control no and its respective insured id. I need to have pair of these values in single line separated by some special character, so that I could use... (2 Replies)
Discussion started by: swame_sp
2 Replies

8. Shell Programming and Scripting

Post Shell programming: Question about source a file and read data from the file

This is shell programming assignment. It needs to create a file called .std_dbrc contains STD_DBROOT=${HOME}/class/2031/Assgn3/STD_DB (which includes all my simple database files) and I am gonna use this .std_dbrc in my script file (read the data from the database files) like this: .... (3 Replies)
Discussion started by: ccwq
3 Replies

9. Shell Programming and Scripting

Read from data file

Hi, I have a data file formatted like this: Ex: Mike 3434 Jack 481 Peter 12 Alan 926 I want to get this data into 2 variables: "Names" and "Numbers" that I can using one "for" loop to get the value as Names and Numbers Like this: for i in 0 1 2 3 do echo $Names echo... (12 Replies)
Discussion started by: fongthai
12 Replies

10. Shell Programming and Scripting

Read data from a file into a variable

I am a FORTRAN guy and not a UNIX expert by any means so sorry if this sounds dumb, but all I want to do is have a UNIX script which reads data from a file (say 1000 lines worth, each row is a file name) and store it in an array to perform an operation on later. As maddeningly simple as this... (2 Replies)
Discussion started by: yorkdg
2 Replies
Login or Register to Ask a Question