Questions tagged [grep]

grep is a command-line tool for searching text patterns in files.

The grep utility searches a pattern (regular expression) in a text file. There are many options to control how matches are performed and how to display matches.

External references

Tutorials

Further reading

See also grep on Unix & Linux Stack Exchange for more detailed reading.

326 questions
-1
votes
1 answer

Copy/Move Entire Line To End Of The Line Above

I have a file that looks like the following: /path/to/a/very/long/path 0 0 0 0 0 0 I need to move the line starting with a number (this can be any value not necessarily 0) to the end of the preceding line so that it looks like the…
djc72uk
  • 33
  • 1
  • 6
-2
votes
1 answer

finding a string among several zipped files (webapps)

We have to find a string, let's say "foobar" among several webapps. However, some webapps contain zipped files, eg log4j.jar. Therefore, grep -IR "foobar" /pathto/tomcatroot/ won't work, because of compressed files. unzip -c…
bgtvfr
  • 1,262
  • 10
  • 20
-2
votes
1 answer

Listing all packages, but without addional text

In this time I am working of project, what tell you, what software you have installer and what you can install. In this time I have problem with this command: grep -hn Package: /var/lib/apt/lists/* . This command returns me package names, that's…
-2
votes
1 answer

How to turn this into an alias?

I frequently use this command: grep -rnw donkey | grep market | cut -c -80 How can I change it into an alias on Linux? I tried: alias search='grep -rnw $1 | grep $2 | cut -c -200' But when I run it with search hello world it gives me: cut: Usage:…
Ginger
  • 103
  • 6
-2
votes
1 answer

Grep is not working without having read permissions

I am in a folder where I do not have read permission in contents. ls -l List all files sucessfully. I want to count files that have some attributes in their name with: ls -l | grep file????.tar.gz | wc -l The command above generates a lot of…
Mini Fridge
  • 149
  • 1
  • 5
-2
votes
2 answers

how to replace one url with another using sed inplace replace in multiple files?

As you can see in the script example down there, I'm trying to find and replace (inplace replace) a string which is part of an URL with another string (url part) within ALL files found with that pattern of URL. In other words, all *.txt files which…
Axel Werner
  • 156
  • 1
  • 12
-2
votes
1 answer

matching any part of a expression using grep

How Can I use grep so as to return me all matches for not only entire expression but also any part of the expression. example: grep "foobar" foo where foo contains text foo should give me a match
debtk
  • 3
  • 2
-2
votes
2 answers

Linux Bash Scripting using grep sed and cut command to display ip address with port number

Can any one please help me I need a output of "192.168.1.1#53" by using these 'grep' 'sed' and 'cut' command mandatory in linux bash scipting in given below text. ;; Query time: 29 msec ;; SERVER: 192.168.1.1#53(192.168.1.1) ;; WHEN: Sat Sep 19…
-3
votes
1 answer

Plesk Unable to exec utility listmng: Cannot find grep program System error 2: No such file or directory

I have a little problem with my plesk installation at the moment and unfortunately do not have enough knowledge to solve it on my own. I would therefore be glad if I could get a hint on this. I tried to log in into my Plesk but I can't proceed due…
MrSnoozles
  • 111
  • 2
-4
votes
3 answers

grep only returns help text

Well, I am perplexed. I am working with an Ubuntu server and I type in grep 'bash' *.sh BUT fgrep 'bash' *.sh works like a champ. which grep and which fgrep both point to their respective executables in /bin. I am perplexed as to what I am…
Pete Mancini
  • 101
  • 2
-5
votes
3 answers

Search for a word before white-space

I've got a file with some e-mails: info@example.com info51351@hotmail.com test@hello.com test6261@gmail.com example@example.com example64262@gmail.com And now... I need to find a way to search for specific e-mails address from the list on the left…
M4tt
  • 1
  • 2
1 2 3
21
22