LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 08-15-2012, 11:37 PM   #1
padeen
Member
 
Registered: Sep 2009
Location: Perth, W.A.
Distribution: Slackware 14, Debian 7, FreeBSD, OpenBSD
Posts: 182

Rep: Reputation: 35
Bash command line backreference


Using lists on the bash command line, is there a way to reference a parameter appearing earlier in the command list?

For example, I have two common use cases:
Code:
mkdir XXX && cd XXX
If I type these two commands separately, after the mkdir I would type cd <alt-.><Enter>.

Or I could do
Code:
mydir=XXX mkdir $mydir && cd $mydir
but that is more typing than I want.

The second use case is similar:
Code:
chmod +x XXX && mv XXX bin
Same deal.

Ideally, I would like to type something like
Code:
chmod +x XXX && mv <alt-2> bin
where readline would dereference alt-2 to the third word in the first command.

Is there such a feature in readline?

Thanks,
Nick

Last edited by padeen; 08-15-2012 at 11:39 PM.
 
Old 08-16-2012, 04:56 PM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 91

Rep: Reputation: 8
Hello Nick,
If I understand what you're asking, I think you can get it with "!:2". Check http://www.gnu.org/software/bash/man...rd-Designators
Regards,
Esteban
 
  


Reply

Tags
bash


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: command works at command line, but not via an alias porphyry5 Programming 3 03-17-2012 03:48 PM
how to use pipe (|) in a one-line bash command gstt Programming 4 10-06-2010 08:54 PM
[SOLVED] bash command line arguments izghitu Linux - Software 4 07-01-2010 10:23 AM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 12:21 PM
One line command - bash da_marius Linux - General 3 11-06-2007 01:24 AM


All times are GMT -5. The time now is 10:20 PM.

Main Menu
Advertisement
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