It is currently Tue, 07 Dec 2021 02:39:59 GMT



 
Author Message
 How to find the first readable word in one line
I hope to find all the line in a file which the first readable word is
"input".

This line may have some spaces or tabs at the begin of the line.

such as

input ....................
input ..............
   input ............

thanks in advance.



 Sun, 01 Jul 2007 10:47:07 GMT   
 How to find the first readable word in one line

awk '$1=="input"' file

        Ed.



 Sun, 01 Jul 2007 10:53:17 GMT   
 How to find the first readable word in one line

Your post shows no evidence that you have actually tried to solve this.
If you get flamed, it's your own fault. Try

man grep
man awk

or some other man page first. Or do you prefer others to do the work for
you?

Another option, using grep (GNU grep) 2.5

grep input file

Michael

In article <1105498027.670137.202...@f14g2000cwb.googlegroups.com>,



 Wed, 04 Jul 2007 12:26:24 GMT   
 How to find the first readable word in one line

a) grep -E '^[ \t]*input([ \t]|$)' yourfile
b) sed -ne '/^[ \t]*input[ \t]/p' -e '/^[ \t]*input$/p' yourfile
c) perl -lne'print if/^\s*input(\s|$)/' yourfile
d) while IFS= read -r Line; do
unset IFS
set x $Line;shift
case $1 in 'input') printf '%s\n' "$Line";; esac
IFS=
done < yourfile
e) awk '{if($1 "" == "input"){print}}' yourfile



 Wed, 04 Jul 2007 13:27:02 GMT   
 
   [ 4 post ] 

Similar Threads

1. one liner which prints n lines before and m lines after the line found by grep

2. From as first word in a line in mail

3. first word of each line

4. catching first words of a multi-line text

5. add one word to line which contains..

6. how to grep one word from a line

7. Lines selection where the first character equals the last one

8. finding files with words that may be on different lines

9. How to find if the last line ends with a specified word

10. How to find the last line that contains a word in file


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software