Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying two file extensions in bash complete

I am trying to modify bash complete properties.

I can exclude a file extension for a command thusly:

complete -f -X '*hi' vim

I want to specify two file names for exclusion. How do I do this?

Note: the following command did not work.

complete -f -X '(*hi|*o)' vim
like image 717
user3458168 Avatar asked Apr 04 '14 06:04

user3458168


People also ask

How do I change all file extensions in Linux?

Change File Extensions From the Terminal And if you want to change the extension (or the name), you'd use the mv command. mv stands for "move" and is the standard command on Linux for moving and renaming files.

How do I write a file extension in Bash?

Using Bash, there's also ${file%. *} to get the filename without the extension and ${file##*.} to get the extension alone. That is, file="thisfile.


1 Answers

One way to do this is to turn on Extended Globs. Run this at the command line, or add it to your .bashrc to make it permanent:

shopt -s extglob

Now, your complete command can look like this:

complete -f -X '*.@(hi|o)' vim

Quoting from Extended Globs in patterns:

@(list): Matches one of the given patterns.
like image 142
devnull Avatar answered Sep 19 '22 14:09

devnull