Fetching data particular data from the file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetching data particular data from the file.
# 1  
Old 08-02-2014
Fetching data particular data from the file.

Hi All,
I have one fine which contaning the record as below, I need to fetch the number which is in Bold and from second line only URL [which is in BOLD and its in other line] need to pick.
Code:
[02-Aug-14 16:04:00] :ABCD                 C7QyzBXIs58k                                  1                       fdmlksdlkfn
                                                                                                                                                                    [02-Aug-14 16:04:03] EFGH                      vl3E2smh2f2                                          200                    kljnsdkljfksdf   
                                                  https://msdnf.nbdsmnf.com/         
[02-Aug-14 16:04:08] IJKL                        AWn65mmn                                            500                                       klsdjflkjsdklf 
                                                   https://wlpqlml.mpc/cpr.htm

the new data or fetched data from the above file should be like...
Please help.

Last edited by Corona688; 08-08-2014 at 12:47 PM.. Reason: data format wrong
# 2  
Old 08-02-2014
Code:
awk '
   NR%2 {match($0,/ [0-9]+ /); n=substr($0,RSTART,RLENGTH); next}
	{print $0, n}
' file

# 3  
Old 08-02-2014
Try also
Code:
awk 'NR%2 {getline X; print X, $5}' file4
https://wmknsm.pwddmslkf.com 1
https://msdnf.nbdsmnf.com/ 200
https://wlpqlml.mpc/cpr.htm 500

# 4  
Old 08-08-2014
error

Thanks ,but for both the code its giving a same error as below

Code:
# awk 'NR%2 {getline X; print X, $5}' test.log
awk: syntax error near line 1
awk: bailing out near line 1

#awk 'NR%2 {match($0,/ [0-9]+ /); n=substr($0,RSTART,RLENGTH); next} {print $2,5}' test.log
awk: syntax error near line 1
awk: bailing out near line 1

Pls help

Last edited by Corona688; 08-08-2014 at 12:47 PM..
# 5  
Old 08-08-2014
Use nawk
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fetching the required data out of a tabular form

Hello Gurus, I am trying to fetch a required number of lines from an output of a command which is in tabular form. Below is the command for reference along with how the result is being shown on UNIX shell. /usr/openv/volmgr/bin/vmquery -b -p 5 The result of the above command is as... (6 Replies)
Discussion started by: Ali Sarwar
6 Replies

2. Shell Programming and Scripting

Fetching data from file

Hi All, I'm facing issue while using script. Chk_Etl_Status=`cat /dstage/questnet/qnetdv/input/Etl_Status.dat|cut -d"," -f1` echo Chk_Etl_Status=$Chk_Etl_Status above result is giving me sometime value as 1 and sometime error message as Chk_Etl_Status= dsjoblaunch.sh: test: Specify a... (5 Replies)
Discussion started by: Amit786
5 Replies

3. Shell Programming and Scripting

Problems with fetching data from Oracle database

Here's a database query which looks up the NAME column of PRODUCT table SELECT NAME FROM PRODUCT ; And this query retrieves me the following output SUGAR COCOA HONEY WHEAT CABBAGE CAULI FLOWER Please note the last record CAULI FLOWER contains TWO blank spaces between the two words. ... (4 Replies)
Discussion started by: kumarjt
4 Replies

4. UNIX for Dummies Questions & Answers

Mapping a data in a file and delete line in source file if data does not exist.

Hi Guys, Please help me with my problem here: I have a source file: 1212 23232 343434 ASAS1 4 3212 23232 343434 ASAS2 4 3234 23232 343434 QWQW1 4 1134 23232 343434 QWQW2 4 3212 23232 343434 QWQW3 4 and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies

5. Shell Programming and Scripting

Formatting Report and Reading data and fetching the details from contents file

Data I was trying to write shell script which will be return the output in the below format First i was trying to do these using sed. sed -n '/.ksh/p' mainksh.ksh sed -e 's/*\(.*\)/\1/g' mainksh.ksh $RUN_DIR, $SUB_DIR and the variables which will be defined in the profile file. when i am... (0 Replies)
Discussion started by: rameshds
0 Replies

6. Shell Programming and Scripting

Fetching data from .csv file

Hi Experts, I have created a table with columns as empname,empid,phone,shiftname. Now I am having a .csv file format which contains the shift datas of the employees. I have to fetch this file and compare with the table I created to send an alert to the specified user. (2 Replies)
Discussion started by: micky3112
2 Replies

7. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

8. Programming

Problem FETCHing Long data type using CURSOR

Currently my Pro*c program is fetching a cloumn which is defined as LONG in oracle db. The data in the column is around 65k. But when I am FETCHing it to a varchar variable, I am only getting 22751 bytes of data using cursor. Is there any limitation on the data which is fetched by a cursor in... (2 Replies)
Discussion started by: manbt
2 Replies

9. Shell Programming and Scripting

Logs access in windows fetching the data from a unix server

How I can get the logs that are getting stored in specific location in unix server through an Apache web server installed in unix server? Requirement is to access the logs through the URL in windows browser without any access. (1 Reply)
Discussion started by: alvida
1 Replies

10. Shell Programming and Scripting

fetching data from sybase using perl

How can I fetch and retreive data(of each result set) of multiple result set from sybase by calling a stored procedure using perl DBI module on an unix solaris environment????? Please help (3 Replies)
Discussion started by: wadhwa.pooja
3 Replies
Login or Register to Ask a Question