unix grep command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix grep command
# 1  
Old 09-19-2006
unix grep command

I need to seach all strings that matches "if [ 1 -eq 2 ]; then" in all files

If i put
grep "if [ 1 -eq 2 ]; then" *.* it is not giving any result
# 2  
Old 09-19-2006
can you see if your version of grep have the -F switch? if yes, then you could use it for your case
Quote:
-F Match using fixed strings. Treat each pattern speci-
fied as a string instead of a regular expression. If
an input line contains any of the patterns as a con-
tiguous sequence of bytes, the line will be matched. A
null string matches every line. See fgrep(1) for more
information.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help on UNIX grep command for numbers

I have a list of files like below, Do we have grep command to find files? If i grep 03874 it should display the file 3874, Grep command should ignore 0 at the beginning. There could be more many leading 0's in filename. $ ls -ltr total 5 -rw-r--r-- 1 mqm mqm 15 Feb 19 17:07 4769... (3 Replies)
Discussion started by: prince1987
3 Replies

2. Shell Programming and Scripting

Grep command giving different result for different users for same command

Hello, I am running below command as root user #nodetool cfstats tests | grep "Memtable switch count" Memtable switch count: 12 Where as when I try to run same command as another user it gives different result. #su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Discussion started by: Pushpraj
10 Replies

3. Shell Programming and Scripting

Help with using grep command with copy command

Hi, im taking an entry Unix class, and as part of my lab assignment I have to copy all files in the /home/david/lab3 directory that have the file extension .save to your lab3/temp directory. I'm having trouble getting the grep to do anything worth while I've been trying to do: cp... (6 Replies)
Discussion started by: Critical jeff
6 Replies

4. UNIX for Advanced & Expert Users

unix command : how to insert text at the cursor location via command line?

Hi, Well my title isn't very clear I think. So to understand my goal: I have a script "test1" #!/bin/bash xvkbd -text blabla with xbindkeys, I bind F5 key in order it runs my test1 script So when I press F5, test1 runs. I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Discussion started by: xib.be
0 Replies

5. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

6. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

7. UNIX for Dummies Questions & Answers

| help | unix | grep - Can I use grep to return a string with exactly n matches?

Hello, I looking to use grep to return a string with exactly n matches. I'm building off this: ls -aLl /bin | grep '^.\{9\}x' | tr -s ' ' -rwxr-xr-x 1 root root 632816 Nov 25 2008 vi -rwxr-xr-x 1 root root 632816 Nov 25 2008 view -rwxr-xr-x 1 root root 16008 May 25 2008... (7 Replies)
Discussion started by: MykC
7 Replies

8. UNIX for Dummies Questions & Answers

Unix grep/test command

Hello, i have a script which checks if the user entered 8 numeric characters in the form of YYYYMMDD (birth date). If the user entered any non numeric characters, an error will be displayed: # Check to see if the 8 characters are all numbers # If not show error essage # And prompt user... (4 Replies)
Discussion started by: netmaster
4 Replies

9. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies

10. UNIX for Advanced & Expert Users

how to exclude the GREP command from GREP

I am doing "ps -f" to see my process. but I get lines that one of it represents the ps command itself. I want to grep it out using -v flag, but than I get another process that belongs to the GREP itself : I would like to exclude # ps -f UID PID PPID C STIME TTY TIME CMD... (2 Replies)
Discussion started by: yamsin789
2 Replies
Login or Register to Ask a Question