grep -v *[^:] Why did this repeat a command i ran earlier today?

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users grep -v *[^:] Why did this repeat a command i ran earlier today?
# 1  
Old 02-03-2010
grep -v *[^:] Why did this repeat a command i ran earlier today?

I ran grep -v *[^:] trying to reverse grep a word before a colon, and discovered it runs a command I had run earlier today.

# 2  
Old 02-03-2010
It will never run a command.

But there are chances that after -v option, the pattern is not quoted. So that is taking all file as input & printing everything ....

Can you please explain the question better if you want us to answer exactly.
# 3  
Old 02-04-2010

The geek is spot on of course. See this example

jonas merzky /tmp : l
-rw-------  1 user   group  10 Feb  3 02:10 file_1
-rw-------  1 user   group  10 Feb  3 02:10 file_2:
-rw-------  1 user   group  10 Feb  3 02:10 file_3:=

with quoting, the grep does what it is expected

jonas merzky /tmp : grep -v '*[^:]'

w/o quoting, your shell will expand the command, and in particular the * will expand to all file names in the directory:

jonas merzky /tmp : echo grep -v *[^:]
grep -v file_1  file_3:=

*[^:] more specifically expands to 'all files which do not end in a colon'. The expanded command is what is being run, with different results than you intented I guess...
# 4  
Old 02-04-2010
I think I know what happened, I copied the output of that command to a file and this grep read the whole file which made it look like it was running the command again.. the command was dtrace, and I had output the stdout to a text file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. UNIX for Dummies Questions & Answers

How to Repeat history command?

Assume i have typed 4 commands in the past like vi `ls -t |head -n 1` tail -2 test.txt ls -lrt | grep "/etc/profile.d" pwd Now if i type r p it should execute the command "pwd" likewise r t should execute tail -2 test.txt. Note: esc k and using up arrow and down arrow will get this work... (3 Replies)
Discussion started by: Ramanareddygv
3 Replies

3. Shell Programming and Scripting

Checking if command ran in parallel

Hi, I am running below code For I in $var do .......some line of code....... nohup Sqlplus apps/apps <<EOF & My_proc($I) Exit EOF done Nohup and & is used for parallel processing. Can someone help in determining if the procedure with different arguments Was called paralley or... (3 Replies)
Discussion started by: Pratiksha Mehra
3 Replies

4. Shell Programming and Scripting

Grep out only today's date

Hi, I have some log files. I've been asked to grep out error messages that have happened ONLY today. (However, the logs keep messages a long time so they have error messages going back weeks) They log details in these fields (order): Month Day Time Server message I can grep out the... (8 Replies)
Discussion started by: horhif
8 Replies

5. UNIX for Dummies Questions & Answers

find the no of processes that ran 2 hours before or earlier

Is there a way to find out the total no of processes that were running ? - 2 or 3 hours before - list those no of processes (3 Replies)
Discussion started by: jansat
3 Replies

6. UNIX for Advanced & Expert Users

Repeat output of last command w/o repeating last command

Is there a way to repeat the output of the last command for filtering without running the command again? All I could think of was to copy all the data to a text file and process it that way, is there another way? Like say I want to grep server.server.lan from a dtrace that was pages long after I... (5 Replies)
Discussion started by: glev2005
5 Replies

7. Shell Programming and Scripting

which user ran which command

can we come to know all the command ran bya user for last 1 day (1 Reply)
Discussion started by: narang.mohit
1 Replies

8. Shell Programming and Scripting

grep data lessthan today's date

Hello All, I have a flat file which contains a field with date information. I want to extract the data less than 2 days before without using 'if' Command. ie. Contents from a file like .. Ajay,12-jan-09 rajiv,10-jan-09 Nalini,02-jan-09 Sunil,14-jan-09 Pankaj,11-jan-09 As... (2 Replies)
Discussion started by: ssachins
2 Replies

9. Shell Programming and Scripting

Repeat last entered command ?

Hi, how to do that ? I mean only print it but not execute. I'm using putty to interact with ksh. (in windows cmd up arrow does the job) thanks vilius (5 Replies)
Discussion started by: vilius
5 Replies

10. UNIX for Advanced & Expert Users

i am not able to recall the command typed earlier in unix

i am not able to recall the command typed earlier in unix whenever i press esc key ^[ comes on the unix prompt . so esc k isnt working for me whenever i press backspace key i get ^H on my unix cursor need help (1 Reply)
Discussion started by: murli1200
1 Replies
Login or Register to Ask a Question

Featured Tech Videos