LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-22-2009, 09:51 PM   #1
frerejacques
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
tricky syntax for passing arguments in csh aliases


I want to write a little time-saving alias for my .cshrc file that will move files and then cd to the directory I've moved them to. What I can't quite figure out is the syntax to say 'move all the arguments except the last one.' Here is what I have:

alias follow 'mv \!:1-$-1 \!:$; cd \!:$'

This actually seems to work, but it also gives me an irritating error:

mv: cannot stat `destinationdirectory/-1': No such file or directory

Similarly, I tried:

alias follow 'mv \!:*$#argv-1 \!:$; cd \!:$'

Again the move and cd are successful, but again there is an error:

mv: cannot stat `destinationdirectory/0-1': No such file or directory

I can guess that the problem is in getting the alias command to parse my expression the way I would like it to, but I can't figure out quite what will make it happy. Please let me know if you have any ideas.

Thanks,

Jeff
 
Old 03-23-2009, 03:20 PM   #2
frerejacques
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Original Poster
Rep: Reputation: 0
answered my own question

Okay, I came across the answer I was looking for on http://www.tcsh.org/tcsh.html/History_substitution.html. The syntax for "from argument x to the last argument, but one" is apparently just x-. So the alias I want is:

alias follow 'mv \!:1- \!:$; cd \!:$'
 
  


Reply

Tags
aliases, arguments, csh, cshrc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wrap lines at 80 for long aliases in .aliases.csh jhwilliams Linux - Software 0 07-26-2007 07:49 AM
bash, passing arguments Four Linux - Newbie 3 02-06-2006 08:24 AM
Problem with passing arguments in Perl bahadur Programming 1 05-30-2005 01:47 AM
passing a list of arguments to a command hdagelic Linux - General 2 05-09-2005 09:30 AM
Handline passing arguments in C AMMullan Programming 9 03-22-2004 01:37 AM


All times are GMT -5. The time now is 05:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration