Unix command help required


 
Thread Tools Search this Thread
# 1  
Unix command help required

Hi All,

Can anyone please help me in sort out the command to get the following command

say File abc.log contains

....
......
This is the first line
This is the second line
This is the third line
This is the fourth line
This is the fifth line

This is the first line
This is the second line
This is the third line
This is the fourth line
This is the fifth line
........
..

..


output
=====
This is the first line
This is the fourth line

Output should be the first search occurence and the second occurence only . But when i trued i was getting the lines all between the first occurence and second search occurece.


Hoping any one of can help me out


thanks
Satish
# 2  
I'm sorry I don't understand the question, you speak about first and second occurrences, but this does not seem to correspond with the required output.
# 3  
Below is the sample file:

","200USD",11,"1e58d7d167c35"
"1e0f117d167c35",12,"<BasicPage>
<DateOfBirth>08/03/1982</DateOfBirth>
<dasda>
<dasdfaf>
<AddressGroup>
<AddressLine1></AddressLine1>
<AddressCity></AddressCity>
<AddressState></AddressState>
......


output :
=======

200USD ( This is in the first line)
<DateOfBirth>08/03/1982</DateOfBirth> ( this is in the inbetween xml)


Thanks
Satish

Last edited by thaduka; 10-17-2005 at 11:02 AM..
# 4  
Looks like you want all the lines between the tags BasicPage and DateOfBirth

Try this.

Code:
sed -n -e '/BasicPage/p' -e '/DateOfBirth/p' input.txt

# 5  
thanks for quick replying.

I want only the lines of tags BasicPage and DateOfBirth.

anyone Please help me in sorting of this command

thanks
Satish
# 6  
Error do not post client-specific data online

please do not post client-specific data online ... you might want to edit your post to remove the data unless you prefer to run into issues with client confidentiality laws ...
# 7  
Quote:
Originally Posted by thaduka
thanks for quick replying.

I want only the lines of tags BasicPage and DateOfBirth.

anyone Please help me in sorting of this command

thanks
Satish
Only the data between the tags or the lines containing the tags as well ?

For the latter, did you try the sed command provided ?

Edit. Just like JustIce said, modify your post to remove the client info. Unless it is a generated info.
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #906
Difficulty: Easy
A Unix shell repeatedly prints a prompt, waits for a command line on stdin, and then carries out some action, as directed by the contents of the command line.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to search a text in file and retrieve required lines following it with UNIX command?

I have requirement to search for a text in the file and retrieve required lines that is user defined with unix command. Eg: Find the text UNIX in the below file and need to return Test 8 & Test 9 Test 1 Test 2 Test 3 Test 4 UNIX Test 5 Test 6 Test 7 Test 8 Test 9 Result can... (8 Replies)
Discussion started by: Arunkumarsak4
8 Replies

2. Shell Programming and Scripting

Required Command in awk command

Hi Firends, I wanted to extract the first record of the file which starst with character say "X". And I tried an awk command which works when i try to execute it individually: awk 'substr($1,1,1)=="X"' inputfile.txt But when I use the same command in my script for which I am passing the... (2 Replies)
Discussion started by: Ajay Venkatesan
2 Replies

3. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

4. Cybersecurity

Help Required: Command to find IP address and command executed of a user

Hi, I am trying to write a script which would figure out who has run which command and their IP. As i dont have any clue as to which commands would do this job, i request some gurus to help me on this. Thanks Vishwas (2 Replies)
Discussion started by: loggedout
2 Replies

5. Shell Programming and Scripting

Help Required regarding wc command

Hi guys, I want to find the number of records in a particular file and store that value in any other variable. I am trying this below command but it is not working and giving me an error "Uninary Operator Expected". say I have taken a variable name 'count' in which I have to store the no. of... (7 Replies)
Discussion started by: dtidke
7 Replies

6. UNIX for Advanced & Expert Users

Required unix command!!!

Hi, In a file I have data like... -rw-r----- 1 ftpuser users 1036695 Jul 6 14:59 ./APRIL 2007/Ujjain/My Disc (D)/9565DW07.04B -rw-r----- 1 ftpuser users 124080 Jul 6 14:59 ./APRIL 2007/Vadodara/vad_APRIL07/2082DW07.04B The above data is extracted using "find . -name... (12 Replies)
Discussion started by: ronald_brayan
12 Replies

7. UNIX for Advanced & Expert Users

help required in unix command/script

Hi All, Please help me in writting the script File contains: ========= 11424444, <basicpage> jfalfksf <dateofbirth>10/02/2005</dateofbrith> jkaklgja lg'd .... 11423224444, <basicpage> jfalfksf <dateofbirth>11/02/2005</dateofbrith> jkaklgja lg'd 11433523224444, <basicpage>... (1 Reply)
Discussion started by: thaduka
1 Replies

8. UNIX for Dummies Questions & Answers

Help Required in Unix Command

Hi All, Can anyone please help me in unix command Query: ==== File contains data along with date and time stamp like, .. Date: 08:23:2005 01:00:00 method: xyz init variables Date 08:23:2005 01:00:01 method: xyz finished init variable .... (2 Replies)
Discussion started by: thaduka
2 Replies

9. Solaris

unix command required.

I need to get a few details from the command line. I need to get the kilobytes per second that my server is transfering to another or has available and I need to test the connection to make sure that its a sound connection. I also need to keep track of the response time. I have been playing... (1 Reply)
Discussion started by: nowayin
1 Replies

10. UNIX for Dummies Questions & Answers

UNIX PATH info required PLEASE HELP (I'm new to unix)

I need to know how to enter a unix path in a cgi script for a guest book: example: My URL is http://www.kitachi.info I have an html file in the main folder on my site, the file is called : gbook.html what would the correct unix path for this file be ??? the part of the script... (1 Reply)
Discussion started by: akitachi
1 Replies

Featured Tech Videos