how i can fetch some strings like words or some words
dears
i need fast command to get some word in documents and copy the lines which contain these words to another file so example if i have file called tota.txt and hold many lines contain word " manager" how i can filtarized the lines which hold word manager and copy it to another file i use some command like sed -n -e '/manager/p' > /tmp/test =====> as example only is that right |
Code:
cat tota.txt | grep -e 'manager' > /tmp/test |
grep is generally the program to use for matching and printing lines.
sed is a more powerful program that allows you to modify the text as well, so it's really overkill here, but yes, it can also be used as a grep substitute. Code:
grep 'string' infile > outfile |
Just to elaborate on the sed solution:
Code:
sed -n '/string/p' infile For example: Code:
sed -n '/love/p' file Quote:
Code:
sed -n '/\<love\>/p' file |
Quote:
|
Good catch. But that's true of both commands. It's really the unbounded regular expression that's matching the substring.
grep however will still match substrings even if you use the -F option to disable regex. In which case you can also use the -w option to have it match whole words. |
thanks
thanks all i really thank you all
|
All times are GMT -5. The time now is 04:31 PM. |