Extract parts of the line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract parts of the line
# 1  
Old 05-03-2016
Extract parts of the line

I have a long list of lines in a txt file which i'm only interested to extract the list of domains like the colored ones.

Code:
domain.com    domain.com/page   codes $.09 
domain.org     domain.org/page2/  codes $0.10
domain.net     domain.net/page03  codes  $0.05
domain.info    domain.info/page34  codes  $0.11
domain.asia  ....
domain.oi ....
domain.world...

how do i extract these red ones from a text file to another text file? please
# 2  
Old 05-03-2016
Hi,

Try awk '{ print $1 }' input_file > output_file where input is your existing file and output is the name of the file where you want the data.

Regards

Gull04
# 3  
Old 05-03-2016
grep
Code:
grep -o 'domain\....' file

# 4  
Old 05-03-2016
thanks alot. very helpful awk '{ print $1 }'
solved my case. grep did almost the same thing with the first solution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split line in 4 parts

Hi Guys, I have file A.txt 1 2 3 4 5 6 7 8 9 10 11 Want Output :- 1 2 3 (3 Replies)
Discussion started by: pareshkp
3 Replies

2. Shell Programming and Scripting

Incrementing parts of ten digits number by parts

I have number in file which contains date and serial number: 2013101000. The last two digits are serial number (00). So maximum of serial number is 100. After reaching 100 it becomes 00 with incrementing 10 which is day with max 31. after reaching 31 it becomes 00 and increments 10... (31 Replies)
Discussion started by: Natalie
31 Replies

3. Shell Programming and Scripting

Extract Parts of File

Hello All, I have a file like this Define schema flat_file_schema ( a varchar(20) ,b varchar(30) ,c varchar(40) ); (Insert into table ( a ,b ,c ) values ( 1 ,2 ,3 ); (4 Replies)
Discussion started by: nnani
4 Replies

4. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

5. Shell Programming and Scripting

Format Parts of Multiline Section to Single Line

Hello, I have an input file that I need formatted. I was hoping I could use bash to get this done. Title: Kitchen Blender Washer Dishes Title: Bathroom Toilet Sink Title: Bedroom Bed Desired output would be similar to Results("Blender","Washer","Dishes") (1 Reply)
Discussion started by: jl487
1 Replies

6. Shell Programming and Scripting

extract certain parts from a file

I have a logfile from which i need to extract certain pattern based on the time but the problem here is the time is not same for all days. Input file: Mon 12:34:56 abvjingjgg Mon 12:34:57 ofjhjgjhgh . . . Mon 22:30:00 kkfng . . . Mon 23:12:23 kjgsdafhkljf . . . Tue 01:04:54... (8 Replies)
Discussion started by: gpk_newbie
8 Replies

7. Shell Programming and Scripting

[ask]break line number into several parts

hlow all, i have file with wc -l file.txt is 3412112 line number so I want to break these files into several parts with assumsi line 1-1000000 will be create part1.txt and 1000001-2000000 will create part2.txt and 2000001-3000000 will create part3.txt and 3000001-3412112 will create... (5 Replies)
Discussion started by: zvtral
5 Replies

8. Shell Programming and Scripting

deleting certain parts of a line in perl

I have a filr data.txt. Its contents are Available labels (* indicates activated, I indicates installed, R idicates running): abc-3.0.3 def-3.0.4 xyz-3.1.2-1.0 I want to delete " Available labels (* indicates activated, I indicates installed, R idicates running):" and... (3 Replies)
Discussion started by: lassimanji
3 Replies

9. Shell Programming and Scripting

How to extract some parts of a file to create some outfile

Hi All, I am very new in programming. I need some help. I have one input file like: Number of disabled taxa: 9 Loading mapping file: ncbi.map Load mapping: taxId2TaxLevel: 469951 --- Subsample reads (20%): 66680 of 334386 Processing: tree-from-summary Running tree-from-summary... (21 Replies)
Discussion started by: iammitra
21 Replies

10. UNIX for Dummies Questions & Answers

removing parts of a line with SED

hi, i'm trying to erase all the characters after, and including, the first test test Output: test1 test2 test3 this is what I tried, but didn't work sed "s/*//" file > testfilename any suggestions? thanks, gammmaman (2 Replies)
Discussion started by: gammaman
2 Replies
Login or Register to Ask a Question