Tag Info

Hot answers tagged


There are these options in grep: -A NUM will give you NUM lines after. -B NUM* will give you NUM lines before. -C NUM* both (NUM lines before and NUM lines after). Where NUM is an integer number. In your case grep -A 1 bbb file.txt will give you ccc.


For dealing with difficult file names, it is best to separate the file names with NUL characters. GNU grep supports this with the --null option and xargs supports this with the -0 option. Thus, try: grep --null -rslZ "foo" | xargs -0 sed -i -- "s/foo/bar/g" Using a shell loop grep --null -rslZ "foo" | while IFS= read -r -d $'\0' file do ...


Find is used for filenames. Grep is used to search within a file or files. So for this, we'll use grep. From the root directory you wish to search in, run: grep -r 'shareEventHandler.php\|repToolBroker.php\|loginProctor.php\|messageBroker.php\|emailBroker.php' . grep - search app -r recursive search from this directory down Use "\|" between search terms ...


Try this: <a.*?> Note that there is a trailing space at the end of that expression. Basically it's looking for the <a then anything up to the next > with a space following. The ? is to say 'non-greedy repeat', ie only as much as is required to get to the next >.

Only top voted, non community-wiki answers of a minimum length are eligible