Sponsored Content
Top Forums Shell Programming and Scripting Using first word and print their contents using awk Post 302139739 by cdfd123 on Tuesday 9th of October 2007 03:13:41 AM
Old 10-09-2007
Using first word and print their contents using awk

suppose u hava a file
G1354R tGGC-CGC
D1361N cGAC-AAC
I1424T ATC-ACC
R768W gCGG-TGG
Q1382R CAG-CGG
Q178E gCAG-GAG
Y181C TAC-TGC
.........cont.
So the question is
By searching for first word i.e.character say R
output shud be
R768W gCGG-TGG
R182P CGG-CCG
R189W gCGG-TG
if Q then
Q1382R CAG-CGG
Q178E gCAG-GAG
So.... continue with all characters .i.e. first word ..

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - print file contents except regex

Hello, I have a file which has user information. Each user has 2 variables with the same name like Email: testuser1 Email: testuser1@test.com Email: testuser2 Email: testuser2@test.com My intention is to delete the ones without the '@' symbol. When I run this statement awk '/^Email:/&&!/@/'... (6 Replies)
Discussion started by: rmsagar
6 Replies

2. UNIX for Advanced & Expert Users

print contents of file2 for matching pattern in file1 - AWK

File1 row is same as column 2 in file 2. Also file 2 will either start with A, B or C. And 3rd column in file 2 is always F2. When column 2 of file 2 matches file1 column, print all those rows into a separate file. Here is an example. file 1: 100 103 104 108 file 2: ... (6 Replies)
Discussion started by: i.scientist
6 Replies

3. Shell Programming and Scripting

Using awk to print line starting with particular word

Hi Geeks, Consider this line: driver=c:\folder1\folder2 The above line is contained in a variable say 'var' . I want to copy everything after 'driver=' in to another variable say var2. Please tell me how can this be done. (8 Replies)
Discussion started by: ajincoep
8 Replies

4. Shell Programming and Scripting

search a word and print specific string using awk

Hi, I have list of directory paths in a variable and i want to delete those dirs and if dir does not exist then search that string and get the correct path from xml file after that delete the correct directory. i tried to use grep and it prints the entire line from the search.once i get the entire... (7 Replies)
Discussion started by: dragon.1431
7 Replies

5. Shell Programming and Scripting

How to Print from matching word to end using awk

Team, Could some one help me in Printing from matching word to end using awk For ex: Input: I am tester for now I am tester yesterday I am tester tomorrow O/p tester for now tester yesterday tester tomorrow i.e Starting from tester till end of sentence (5 Replies)
Discussion started by: mallak
5 Replies

6. Shell Programming and Scripting

awk or sed command to print specific string between word and blank space

My source is on each line 98.194.245.255 - - "GET /disp0201.php?poc=4060&roc=1&ps=R&ooc=13&mjv=6&mov=5&rel=5&bod=155&oxi=2&omj=5&ozn=1&dav=20&cd=&daz=&drc=&mo=&sid=&lang=EN&loc=JPN HTTP/1.1" 302 - "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR... (5 Replies)
Discussion started by: elamurugu
5 Replies

7. Shell Programming and Scripting

sed or awk to print 2nd last word

Hi, I have a file which has the following /usr/new/xyz/abc /us1/neb/yxr/def /usr/bin/cloud1/fgh /net/bin1/txt1/kdq I want to do something like this /usr/new/xyz/abc xyz /us1/neb/yxr/def yxr /usr/bin/cloud1/fgh cloud1 /net/bin1/txt1/kdq txt1 I need to add the 2nd last word to the... (3 Replies)
Discussion started by: matbrow
3 Replies

8. UNIX for Dummies Questions & Answers

Script to search for a particular word in files and print the word and path name

Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name". Thanks for the reply in adv,:) (3 Replies)
Discussion started by: virtual_45
3 Replies

9. Shell Programming and Scripting

For loop inside awk to read and print contents of files

Hello, I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
Discussion started by: jaldo0805
5 Replies

10. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies
Hunspell(3pm)						User Contributed Perl Documentation					     Hunspell(3pm)

NAME
Text::Hunspell - Perl interface to the GNU Hunspell library SYNOPSIS
# For this example to work, you have to have # the US english dictionary installed! use strict; use warnings; use Data::Dumper (); use Text::Hunspell; # You can use relative or absolute paths. my $speller = Text::Hunspell->new( "/usr/share/hunspell/en_US.aff", # Hunspell affix file "/usr/share/hunspell/en_US.dic" # Hunspell dictionary file ); die unless $speller; # Check a word against the dictionary my $word = 'opera'; print $speller->check($word) ? "'$word' found in the dictionary " : "'$word' not found in the dictionary! "; # Spell check suggestions my $misspelled = 'programmng'; my @suggestions = $speller->suggest($misspelled); print " ", "You typed '$misspelled'. Did you mean? "; for (@suggestions) { print " - $_ "; } # Analysis of a word $word = 'automatic'; my $analysis = $speller->analyze($word); print " ", "Analysis of '$word' returns '$analysis' "; # Word stemming $word = 'development'; my @stemming = $speller->stem($word); print " ", "Stemming of '$word' returns: "; for (@stemming) { print " - $_ "; } #------------------------------------------ # ADVANCED STUFF FROM HERE # NOT SURE HOW IT SHOULD WORK #------------------------------------------ # # Test here generator for morphological modification (NOM->ACC) # $word = 'developer'; my $stem = 'computer'; @suggestions = $speller->analyze($stem); # Modify analyze output for required class (ACC) for (@suggestions) { s/NOM/ACC/g; } # Generate ACC class of stem @suggestions = $speller->generate2($stem, @suggestions); print "Morphological modification generator... "; print Data::Dumper::Dumper(@suggestions); # # Test generator for morphological modification, # modify $stem like $word # @suggestions = $speller->generate($stem, $word); print "Morphological modification generator... "; print Data::Dumper::Dumper(@suggestions); # Deletes the underlying Hunspell C/C++ object $speller->delete($speller); DESCRIPTION
This module provides a Perl interface to the OO Hunspell library. This module is to meet the need of looking up many words, one at a time, in a single session, such as spell-checking a document in memory. The example code describes the interface on http://hunspell.sf.net DEPENDENCIES
You MUST have installed GNU Hunspell library version 1.0 or higher on your system before installing this "Text::Hunspell" Perl module. Hunspell location is: http://hunspell.sf.net There have been a number of bug reports because people failed to install hunspell before installing this module. This is an interface to the hunspell library installed on your system, not a replacement for hunspell. You must also have one hunspell dictionary installed when running the module's test suite. Also, please see the README and Changes files. README may have specific information about your platform. METHODS
The following methods are available: "Text::Hunspell-"new($full_path_to_affix, $full_path_to_dic)> Creates a new speller object. Parameters are: full path of affix file full path of dictionary (dic) file Returns "undef" if the object could not be created, which is unlikely. "check($word)" Check the word. Returns 1 if the word is found, 0 otherwise. "suggest($misspelled_word)" Returns the list of suggestions for the misspelled word. "analyze($word)" Returns the analysis list for the word. TODO HOW? What does it return?? See the examples in the examples/ folder for now. "stem($word)" Returns the stem list for the word. "generate2($stem, @suggestions)" Returns a morphologically modified stem as defined in @suggestions (got by analysis). TODO Explain ... "generate($stem, $word)" Returns morphologically modified stem like $word. TODO WHY IS THIS DIFFERENT FROM generate2() ??? EXPLAIN. "$speller-"delete($speller)> Deletes the speller class. TODO WHY IS THIS NEEDED?? Called on $speller and needs $speller ??? BUGS
Probably. Yes, definitely. COPYRIGHT
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHORS
Eleonora, E<lt>eleonora46_at_gmx_dot_netE<gt> Current maintainer is: Cosimo Streppone, E<lt>cosimo@cpan.orgE<gt> This module is based on a Text::Aspell written by Bill Moseley moseley at hank dot org. Hunspell is written as myspell by Kevin B. Hendricks. Hunspell is maintained by Nemeth Laszlo. Please see: http://hunspell.sf.net For the dictionaries: http://lingucomponent.openoffice.org/spell_dic.html http://magyarispell.sf.net for Hungarian dictionary perl v5.14.2 2012-06-07 Hunspell(3pm)
All times are GMT -4. The time now is 03:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy