• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

unix command line questions

Special K

Diamond Member
I have the following lines in my .cshrc file:

# Change the format of the command prompt
alias setprompt 'set prompt="${system}:${cwd}[ \! ] --> "'
alias cd 'chdir \!* && setprompt'
setprompt


# These aliases are necessary to make my command prompt display the correct path after using a pushd or popd command

alias pushd 'pushd \!* && setprompt'
alias popd 'popd \!* && setprompt'

This is so the current working directory is always displayed on my command line. I have a few questions about this:

1. Let's say I am in the directory foo/, and I have a symbolic link "bar" that points to this location:

/home/temp/data/

If I type in the command 'cd bar', my command prompt will look like this:

system_name:/foo/bar[ 1 ] -->

instead of like this:

system_name:/home/temp/data[ 1 ] -->

Basically, how do I get the command prompt to resolve symbolic links and display their full paths?

2. What does "\!" (without the quotes) represent? What about "\!*" (without the quotes)? These expressions appear in my .cshrc file above, but I don't understand what they are doing. Google search isn't very good at searching for symbols.
 
Can't help you with question 1, but for 2, man is your friend.

man csh

History substitutions
History substitutions place words from previous command input as portions of new commands, making it easy to repeat commands, repeat arguments of a previous command in the current command, or fix spelling mistakes in the previous command with little typing and a high degree of confidence. History substitutions begin with the character ?!? and may begin anywhere in the input stream (with the proviso that they do not nest). This ?!? may be preceded by a ?\? to prevent its special meaning; for convenience, a ?!? character is passed unchanged when it is followed by a blank, tab, newline, ?=? or (??. (History substitutions also occur when an input line begins with ?^?. This special abbreviation will be described later.) Any input line that contains history substitution is echoed on the terminal before it is executed as it would have been typed without history substitution.

To select words from an event we can follow the event specification by a ?:? and a designator for the desired words. The words of an input line are numbered from 0, the first (usually command) word being 0, the second word (first argument) being 1, etc. The basic word designators are:

0 first (command) word
n n?th argument
^ first argument; i.e., ?1?
$ last argument
% word matched by (immediately preceding) ?s? search
x-y range of words
-y abbreviates ?0-y?
* abbreviates ?^-$?, or nothing if only 1 word in event
x* abbreviates ?x-$?
x- like ?x*? but omitting word ?$?
 
Back
Top