UGU Unix Guru Universe
For Unix Admins, By Unix Admins
Follow ugucom on Twitter      Search  in 
Home
BEGINNERS & USERS

Events

Internet
 
 Linux
BEGINNERS & USERS
Software
Linux Vendors
Usenet NewsGroups
Books & Publications
 
 Shop
Cool Admin Gifts!
Gadgets
T-Shirts
Books
 
 Unix Guru Universe
About
Add Link
Feedback
 
 
UGU: Unix Guru Universe - Unix Tip #4530- August 5, 2024 - Home : Help : Today's Tip
Unix Tip #4530- August 5, 2024

HOW MANY COMMANDS HAVE I RUN?


If you're a csh/tcsh/zsh user, you've seen the supposed feature
that lets you display how many commands you've run in your
prompt:

set prompt="\! %"

The \! (or %h or %! for tcsh) displays not really a current
count of commands run, but the current history event number.

Think of it in those terms, and you'll discover it becomes quite
useful.

For example, how many times have you typed some enormously long
command line, only to have it fail because several other conditions
weren't met?

You spend the next several prompts typing various commands to
get conditions set up just right, and then have to retype the
entire long command.

Or, if it hasn't scrolled off the screen yet, just type ! followed
by the history event number displayed in the prompt for that big
long command. It's that simple:

prompt 23 % command -with some -very +long /argument/list
command: Example command failed.
prompt 24 % cd /to/correct/directory
prompt 25 % rm certain.files
prompt 26 % !23
command -with some -very +long /argument/list
command: Example command succeeds.
prompt 27 %

You can even apply the standard csh modifiers to !. For
example, particularly useful is !:p, which just prints
the command typed on prompt instead of executing it
again:

prompt 26 % !23:p
command -with some -very +long /argument/list
prompt 27 % !!
command -with some -very +long /argument/list
command: Example command succeeds.
prompt 28 %

NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted by various unix admins around the globe. UGU suggest you read and test each tip in a non-volitile environment before placing into production.


LAST 5 TIPS
4529 - VULNERABILITIES IN UNIX
4528 - METAVALUES FROM A SHELL SCRIPT
4527 - WHAT TIME IS IT REMOTELY?
4526 - FTP WITHOUT PROMPTS
4525 - PROCESS EXECUTION TIME


I want to SUBSCRIBE and get a UGU Tip everyday.
I want to UNSUBSCRIBE and NOT get a UGU Tip everyday.

If you have a UNIX TIP let us know, we just may use it:
(All tips become the property of the Unix Guru Universe)
Email Address:

Yes, email me a Hot Unix Tip everday.

Enter Hot Unix Tip (optional):

Yes, I will support this tip

Captcha (not case sensitive):


Please enter the above letters:

 
Copyright 1994-2024 Unix Guru Universe