Printing a line in a file

Hi
I have a file having multiple lines. I want to print a particular line. How can I do this?

Thanks in advance
Ananth

You already have fitting answers in your other threads:

http://www.unix.com/shell-programming-scripting/169313-help-sed.html\#post302565330

Where is the specific problem in this case?

Hi
In those I know what to filter but in this case it can be anything so I need to display all the lines and want to select a particular line and print the same.

Hi,

You can get the line in a file by grep cmd.

grep 'pattern' file

awk '$0 ~ /^pattern/{print;}' file

You can get line by line number( below example gets 10th line).

perl -ne 'if($. == 10){print;}' file

Cheers,
Ranga:-)

1 Like

Anything can be everything so that does not help and a computer doesn't know. If you want to filter more than one pattern, try:

grep -E "pattern1|pattern2|pattern3" infile
1 Like
awk '/ALTER TABLESPACE TEMP ADD/,/MAXINSTANCES 1/' file.txt