I want to copy lines containing certain words from file1
to file2
.
Suppose file1
:
ram 100 ct 50
gopal 200 bc 40
ra
This awk
should do
awk '/ct/' file1 > file2
If position is important
awk '$3=="ct"' file1 > file2
awk '$3~/ct/' file1 > file2
last version is ok if ct
is part of some in field #3
Same with grep
grep ct file1 > file2
-n
is not needed, since it prints line number
Same with sed
sed -n '/ct/p' file1 > file2