It is currently Tue, 30 Nov 2021 17:51:51 GMT



 
Author Message
 : Alias defining
Hello All,
I wrote an alias to extract all the occurrencies of a particular command
into my history.
Here is what I made:

find_history='history|fgrep $1'

As you can try it extract every thing contains the pattern I give after
the command name.
Es.:

bash$ find_history ls

12 ls -l
230 ls -la
....
1021 find_history ls

bash$...

How U can imagine, I don't like to see also the lines where there is the
find_history command. So I modified the previous to:

find_history='history|fgrep $1|fgrep -v find_history'

But this doesn't work as I think, see later the result...

bash$ find_history ls

Usage: fgrep [OPTION]... PATTERN [FILE]...
Try `fgrep --help' for more information.
fgrep: ls: No such file or directory
Broken pipe

bash$ ...

Can you help me?Thanx a lot
Please reply to jan...@technologist.com too.

--
G. Costagliola (jancos)
--------------+------------------------------------
mobile:       | +39 (0)347 1174139
office:       | +39 (0)81 5323466
office/FAX:   | +39 (0)81 5323467
personal FAX: | +39 (0)6 233205937
www:          | http://www.**-**.com/
e-mail:       | jan...@technologist.com (Official)
              | jan...@libero.it
s-mail:       | Via A. de Gasperi, 128
              | 80053 C.mmare di Stabia (NA)
              | ITALY
ICQ#:         | 28211040
--------------+------------------------------------



 Mon, 11 Nov 2002 03:00:00 GMT   
 : Alias defining

1st of all, $1 doesn't work in bash alias:

$ alias test_p='echo 1:$1 2:$2 3:$3'

$ test_p sss ww bbb
1: 2: 3: sss ww bbb

so you have to define a fucntion for your task

2nd, did you realized that the "find_history" IS going to be record into
history?

here is what you want:

find_history(){ history|fgrep $1|fgrep -v find_history; }

and you might want to "unalias find_history" first.

-- Tong
Anti-spam: remove underscore(s) to reply.
Welcome to my homepage http://members.xoom.com/suntong001/
  - All free contribution & collection
  - freeware &  music from the heavens



 Mon, 11 Nov 2002 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Where are aliases defined for /bin/sh?

2. Where are the aliases defined in single-user mode?

3. gcc #define #define #define

4. Aliases in X - where defined?

5. How to define aliases on startup

6. format of user-defined alias file

7. help defining csh alias

8. Define Tcsh Alias with $ Character as Regexp

9. tcsh: define function-like alias


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software