grep command

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep command
# 1  
grep command

I need to search the follwowing syntax in all the file in the directory
How to user grep command

If the below syntax is present it should display

if [ 1 -eq 2 ]; then # scissors
# 2  
can u brief your question?
# 3  
grep command

I have 300 files in the directory. I need to find out below syntax in which files it is available

if [ 1 -eq 2 ]; then # scissors

ps -ef |grep "scissors" *.* (this syntax is not working)
# 4  
Originally Posted by pmsuper
I have 300 files in the directory. I need to find out below syntax in which files it is available

if [ 1 -eq 2 ]; then # scissors

ps -ef |grep "scissors" *.* (this syntax is not working)
What is the control for the test

if [ 1 -eq 2 ];

What are you trying to do with the # as this is commenting out scissors?!

Sorry but what is the ps -ef | grep "scissors *.* supposed to be doing?

Also no fi at the end of the if so it will not work anyway!
# 5  
can u give me the directory structure cos the the syntax what u have given is */* which means that u r searching for a pattern in current directory say

X, 1st * tells to search the pattern in all the directories under X
2nd * i,e /* tells to get into each of * directories under X, search in all the files under each of * directories.

Hope u got my pt.

# 6  

> grep -i scis *
RecreateAIUMajorAccounts:if [ 1 -eq 2 ]; then # scissors venkat

This syntax(if [ 1 -eq 2 ]; then # scissors venkat) is present in the file RecreateAIUMajorAccounts
# 7  
grep '\[ 1 \-eq 2 \]; then' *

Hope this works. I dont know why you are using ps it just lists the processes running in the unix box. The above should help you

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #881
Difficulty: Medium
One many threat vectors to a modern SCADA system is the threat of unauthorized access to the control software,
True or False?

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

grep command

Not sure what I'm doing wrong here???? Trying to execute a grep command within a unix script and keep getting an error. Here is an example of the process I'm trying to execute a="\"JERRY SMITH\""; b="/u/tmp/filea"; x=`grep -c $a $b`; echo $x; Execute script and this is what I get...... (3 Replies)
Discussion started by: macastor
3 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. 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

5. UNIX for Advanced & Expert Users

Grep Command

Hi, I have encountered a problem with grep command. The max characters that grep can supported is 2048 as defined in LINE_MAX in hp-ux. I try setting $TK_GREP_LINE_MAX but this is not workable in HP-UX, anyone has experienced with setting the max characters supported by grep command. Well,... (5 Replies)
Discussion started by: dwgi32
5 Replies

6. 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

7. Shell Programming and Scripting

Help need in Grep Command

Hi I am assaging a variable like this current_dir ='ps -o user|grep -v'USER'|uniq' #this would print the user id " v_name=`date +%m%d%y` outputfile =$v_name$current_dir.txt this gives the output file with timeanddate .txt but not the userid lets assume i have the userrid called... (4 Replies)
Discussion started by: ranga27
4 Replies

8. UNIX for Dummies Questions & Answers

grep command help

Hello, im trying to grep the first 3 lines(starting with ERROR) from an output report and put it in a separate file... any help would be appreciated. Below is the message contained in the report ERROR >Invalid basic data (CMOFCT-5070) Cusip: 05950XAL0 CMO#508039 Tra# 11 rec# 175 Firts Int... (15 Replies)
Discussion started by: geekeezoid
15 Replies

9. UNIX for Dummies Questions & Answers

grep command

Hi, I need to grep two variables at the same time in shell programming. Like today=Dec_16, and $1=5, how can I grep like this: "$today_$1"? Thanks in advance! (5 Replies)
Discussion started by: whatisthis
5 Replies

10. Shell Programming and Scripting

grep command

Hi I have read your article on grep it is very useful. I have a problem using grep , can you please help me to sort out. I am listing the contents of a file below : ##########1003134 05/04/1970F48371008 0736778 6123785090 0E10/13/1997 04/22/1998XSSUB 77 ... (8 Replies)
Discussion started by: Vittal Raj
8 Replies

Featured Tech Videos