LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2009, 06:58 AM   #1
7stud
LQ Newbie
 
Registered: Feb 2007
Posts: 22

Rep: Reputation: 15
file name expansion: vi *lastPart ?


Hi,

I have a several files in a directory with names like:


xxxxxxxxxxxYYYYYYYsssssss-1.txt
xxxxxxxxxYYYYssssYYYYYYY-2.txt
xxxxxxxxxYYYYssssYYYYYxx-3.txt

I know about tab file name completion but in this case it is still a pain. Is there a way I can open one of those files in vi by just specifying the last part of the file name, for example:


vi *1.txt

I'm using a bash shell.

Thanks.
 
Old 04-25-2009, 07:26 AM   #2
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
That should work. Have you tried it?
 
Old 04-25-2009, 07:53 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

Like jay73 stated, that should work. There is one possible catch: If other files in the same dir end with 1.txt, they are also opened. Make sure that the expression used does not give you false hits.
 
Old 04-25-2009, 08:43 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,938

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Another method available would be to hightlight the file name and paste it on the command line using the scroll wheel button.
 
Old 04-26-2009, 12:54 AM   #5
7stud
LQ Newbie
 
Registered: Feb 2007
Posts: 22

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jay73 View Post
That should work. Have you tried it?
lol. Yes, about 10 times, but vi would just open a new file called *3.txt. However, I must have screwed something up because now when I try it, the * expands and the file that I want to edit opens in vi. Ahh...no more tab and type drudgery.

Quote:
Another method available would be to hightlight the file name and paste it on the command line using the scroll wheel button.
With the cursor at the command prompt, highlight the file name and then push down on the scroll wheel? That doesn't do anything when I try it, but I have a crappy mac mouse and now that I think about it pushing down on the scroll wheel used to bring up all the widgets, and now it doesn't do that anymore. I guess I need a new mouse.

Thanks.

Last edited by 7stud; 04-26-2009 at 01:09 AM.
 
  


Reply


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
Variable expansion in BASH champak Programming 5 11-26-2007 03:44 AM
Expansion Port 3 berlingo Linux - Newbie 2 09-22-2007 12:35 AM
File name expansion with {} in gnu find and xargs anamericanjoe Linux - Software 2 09-16-2006 04:31 PM
Does anyone have the expansion pack for 5.2? solid7 AIX 14 04-26-2005 01:18 PM
Raid 5 Expansion Ruckuss Linux - General 3 01-05-2002 06:04 PM


All times are GMT -5. The time now is 04:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration