delete string using AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete string using AWK
# 1  
Old 02-02-2011
delete string using AWK

inputfile has 3 columns

Code:
SCHEMA.TAB1  COL1 LENGTH
SCHEMA.TAB2  COL2 LENGTH.


If i use awk on the above inputfile

awk '{print $1}' inputfile.The out put will be

Code:
SCHEMA.TAB1
SCHEMA.TAB2.

But from the above output i need to delete SCHEMA. i.e i don't want the string "SCHEMA." should display in output.Can some body help me how to code that ?
# 2  
Old 02-02-2011
What should be the desired output?
# 3  
Old 02-02-2011
Just
Code:
TAB1 COL1 LENGTH
TAB2 COL1 LENGTH

i.e string "SCHEMA." should not be display in output
# 4  
Old 02-02-2011
Code:
awk -F\. '{print $2}' file

# 5  
Old 02-02-2011
yes its working fine.Can i know the meaning of this statement?

with out giving $3, and $1 in the ouput how come the SCHEMA. string got depriciated?
# 6  
Old 02-02-2011
Quote:
Originally Posted by rocking77
yes its working fine.Can i know the meaning of this statement?

with out giving $3, and $1 in the ouput how come the SCHEMA. string got depriciated?
With a dot as fieldseparator (-F\.) the second field is the part after the first dot (untill the next dot).
# 7  
Old 02-02-2011
Code:
 $ ruby -ne 'print gsub(/^.[^.]*\./,"")' file 
$ ruby -F"\." -ane 'puts $F[1]' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk Associative Array and/or Referring to Field by String (Nonconstant String Value)

I will start with an example of what I'm trying to do and then describe how I am approaching the issue. File PS028,005 Lexeme HRS # M # PhraseType 1(1:1) 7(7) PhraseLab 501 503 ClauseType ZYq0 PS028,005 Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 Replies

2. Shell Programming and Scripting

awk string comparison unterminated quoted string andrule of thumb

I have the logic below to look up for matches within the columns between the two files with awk. In the if statement is where the string comparison is attempted with == The issue seems to be with the operands, as 1. when " '${SECTOR}' " -- double quote followed by single quote -- awk matches... (1 Reply)
Discussion started by: deadyetagain
1 Replies

3. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

4. Shell Programming and Scripting

awk delete line if $5 contains string from list

(5 Replies)
Discussion started by: chrisjorg
5 Replies

5. UNIX for Dummies Questions & Answers

Delete only commas in a string in AWK

How can I delete just commands in a string. I tried x = gsub(/,/,"",$1); (7 Replies)
Discussion started by: codecaine
7 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

Find number in string and delete it AWK

Hi all, i have some logs on my linux server that looks like this: CDR.2012-04-30:30-04-2012 14:09:36;123456456654;A;Greetings! Your amount is 42.24 dollars (without VAT) until 30/04/2012 11:00. CDR.2012-04-30:30-04-2012 14:09:36;12154878454212;A;Greetings! Your amount is 4203.2 dollars... (2 Replies)
Discussion started by: arrals_vl
2 Replies

8. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

9. Shell Programming and Scripting

delete a string on column1

Hi I have a file with multiple columns. But there is something weird on column one that is attached to the name. The good thing is that its a consistent pattern so there should be a way to remove it. So the first column looks something like this: name_345.4ml date_3456.4ml year_12.4ml... (3 Replies)
Discussion started by: kylle345
3 Replies

10. Shell Programming and Scripting

Delete a comma from string

Hey guys, Its a simple question though, but since I'm new to this shell scripting world ... it's kind of difficult. Say I have some string as : ListenAddress=ABCServer1,ABCServer2 I want to output the value of ListenAddress as ... ABCServer1 ABCServer2 so, basically, I want to... (6 Replies)
Discussion started by: MisterKhan
6 Replies
Login or Register to Ask a Question