I am trying to ignore the order of the words and searching for the line in one file which has below pattern for example : My Name is ABC. Now I want to change the sequence of words in the same sentence as below : ABC is my name. Can someone  please help me on how should I find this line in linux, if the order/sequence of the words keeps changing ? Thanks in advance.
123662
Is there any way to use grep to search for entry matching multiple patterns in any order using single condidion?  As showed in  for multiple patterns i can use   grep -e 'foo.*bar' -e 'bar.*foo'   but i have to write 2 conditions here, 6 conditions for 3 patterns and so on... I want to write single condition if possible. For finding patterns in any order you can suggest to use:   grep -e 'foo' | grep -e 'bar' # at least i do not retype patterns here   and this will work but i would like to see colored output and in this case only bar will be highlighted.  I would like to write condition as easy as   awk '/foo/ &amp;&amp; /bar/'   if it is possible for grep (awk does not highlight results and i doubt it can be done easily).  agrep can probably do what i want, but i wonder if my default grep (2.10-1) on ubuntu 12.04 can do this.
75552
I'm trying to grep for the full sentence containing a search term. I've tried  grep (^.|\.\s).*searchterm.*(\.\s|\n)   but it's not working and I'm not sure why.  To clarify: I want stdout to print the full sentence of the search term. I am using grep to search through a single text file.  As an example, if my file has  "Foo blah. Blah blah searchterm blah blah. Foo bar."  I want stdout to print Blah blah searchterm blah blah
13500
Input file1 is:  dog 123 4335 cat 13123 23424  deer 2131 213132 bear 2313 21313   I give the match the  pattern from in other file ( like dog 123 4335 from   file2).  I match the pattern of the line is dog 123 4335 and after printing all lines without match line my output is:   cat 13123 23424 deer 2131 213132 bear 2313 21313   If only use without address of line only use the pattern, for example 1s how to  match and  print the lines?
77738
cat file_1  my colour is red my rose is red my colour is blue my rose id blue  cat file_2  red blue  cat output_file should be my colour is red my colour is blue   here i am using   cat file_2 | while read line;do cat file_1 | grep "$line" | head -1;done   here i am trying to get the top most line containing the pattern "red" and "blue" which is present in the file_2  is there any other way  to do , as fast as possible, while loop is taking time
77039
I have two files with following contents  file 1:  9/09a-A5 9/09a-A18 9/09b- 2B 9/09a-A9 9/09b- 7 9/09a-A11 9/09a-A14 9/09c- 16 9/09b- 5 9/09b- 12 9/09a-A25 9/09a-A10Y 9/09a-A17Z 9/09a-A12Z 9/09b- 4Z 9/09a-A26Y 9/09a-A13 9/09a-A27 9/09a-A19 9/09a-A10 9/09a-A17Y 9/09a-A4 9/09a-A7 9/09a-A15 9/09b- 1 9/09a-A19Z 9/09a-A26 9/09a-A16 9/09a-A22Z 9/09a-A10Z 9/09a-A26Z 9/09a-A13Z 9/09b- 9 9/09b- 4   file 2  9/09b- 2 9/09b- 2A 9/09b- 2B 9/09b- 4Z 9/8B-13 9/9A-11 9/9A-13 9/9A-13Z 9/9A-14 9/9A-6 9/9A-8 9/9A-A13 9/9B-1 9/9B-10 9/9B-12 9/9B-3 9/9B-4 9/9B-5 9/9B-7 9/9B-9 9/9C-15 9/9C-16 9/9D-17   I want to take row 1 from file 1 and search for same name in file 2, if it is there then print. Please note that there are spaces and upper and lower cases to be ignored while searching. here result should be  9/09b- 2B 9/09b- 5 9/09c- 16 9/09b- 12 9/09b- 4Z 9/09a-A13 9/09b- 1 9/09b- 9 9/09b-
37242
Is it possible to do a multiline pattern match using sed, awk or grep? Take for example, I would like to get all the lines between { and }  So it should be able to match    1. {}  2. {.....}  3. {.....      .....}  Initially the question used &lt;p&gt; as an example. Edited the question to use { and}.
60429
I would like to list all files matching a certain pattern while ignoring the case.  For example, I run the following commands:  ls *abc*   I want to see all the files that have "abc" as a part of the file name, ignoring the case, like  -rw-r--r-- 1 mtk mtk 0 Sep 21 08:12 file1abc.txt -rw-r--r-- 1 mtk mtk 0 Sep 21 08:12 file2ABC.txt   Note  I have searched the man page for case, but couldn't find anything.
86465
For debugging purposes, I need to recursively search a directory for all files which start with a UTF-8 byte order mark (BOM). My current solution is a simple shell script:  find -type f | while read file do     if [ "`head -c 3 -- "$file"`" == $'\xef\xbb\xbf' ]     then         echo "found BOM in: $file"     fi done  Or, if you prefer short, unreadable one-liners:  find -type f|while read file;do [ "`head -c3 -- "$file"`" == $'\xef\xbb\xbf' ] && echo "found BOM in: $file";done  It doesn't work with filenames that contain a line break, but such files are not to be expected anyway.  Is there any shorter or more elegant solution?  Are there any interesting text editors or macros for text editors?
93107
When i am using these commands , i am getting the same output but only order is getting changed for ls -ltr command. Can anyone please tell me what is the difference between the below commands?   ll ls -l ls -ltr
38558
I have a file with the lines like below.  title1:A1 title2:A2 title3:A3 title4:A4 title5:A5  title1:B1 title2:B2 title3:B3 title4:B4 title5:B5  title1:C1 title2:C2 title3:C3 title4:C4 title5:C5  title1:D1 title2:D2 title3:D3 title4:D4 title5:D5  How can I achieve this?   title1    title2     title3    title4 A1         A2         A3         A4 B1         B2         B3         B4 C1         C2         C3         C4 D1         D2         D3         D4
43335
Given a file L with one non-negative integer per line and text file F, what would be a fast way to keep only those lines in F, whose line number appears in file L?  Example:  $ cat L.txt 1 3  $ cat F.txt Hello World Hallo Welt Hola mundo  $ command-in-question -x L.txt F.txt Hello World Hola mundo   I'm looking for a command that can handle a file L with 500 million or more entries; file L is sorted numerically.  Note: I'm halfway through an implementation for a command-in-question but I just wondered, whether one might be able to use some Unix tools here as well.    Update: Thank for all the answers, I learned a lot today! I would like to accept more one answer, but that's not possible.
15133
If I have a file with contents similar to:  FirstSection     Unique first line in first section     Unique second line in first section  SecondSection     Unique first line in second section     Unique second line in second section  ...  NthSection     Unique first line in Nth section     Unique second line in Nth section   Is it possible to use unix commands (e.g. sort, awk) to sort the file alphabetically by the first non-indented line in each three line group, whilst keeping the indented lines under their existing group?
38533
Is there a simple way I can echo a file, skipping the first and last lines? I was looking at piping from head into tail, but for those it seems like I would have to know the total lines from the outset. I was also looking at split, but I don't see a way to do it with that either.
13702
I am trying to search a file for a pattern and if the it is found I want to see the line and 10 more lines of the result.  so far I have  grep -n pattern file | cut -d: f1    now not sure how to use this out put to do the print with the logic like   sed -n result,(result+10)p file   probably  going to have a few issued if it pattern is in multiple lines.  Any help is appreciated
62598
How to replace the third occurrence of the string in the file using sed command. Example: Change only the third occurrence of is to us in the file. My input file contains: hai this is linux. hai this is unix. hai this is mac. hai this is unchanged.  The expected output is: hai this is linux. hai thus is unix. hai this us mac. hai this is unchanged.
54821
I know this question has probably been answered before.  I have seen many threads about this in various places, but the answers are usually hard to extract for me.  I am looking for help with an example usage of the 'sed' command.  Say I wanted to act upon the file "hello.txt" (in same directory as prompt).  Anywhere it contained the phrase "few", it should be changed to "asd".  What would the command look like?
85410
Below is the text in the file:  Pseudo name=Apple Code=42B state=fault  Pseudo name=Prance Code=43B state=good   I need to grep for "42B" and get the output from the above text like:   Pseudo name=Apple Code=42B state=fault   Does anyone have idea on how to achieve this using grep/awk/sed?