LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   file name expansion: vi *lastPart ? (https://www.linuxquestions.org/questions/linux-newbie-8/file-name-expansion-vi-%2Alastpart-721564/)

7stud 04-25-2009 05:58 AM

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.

jay73 04-25-2009 06:26 AM

That should work. Have you tried it?

druuna 04-25-2009 06:53 AM

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.

michaelk 04-25-2009 07:43 AM

Another method available would be to hightlight the file name and paste it on the command line using the scroll wheel button.

7stud 04-25-2009 11:54 PM

Quote:

Originally Posted by jay73 (Post 3520395)
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.


All times are GMT -5. The time now is 08:21 PM.