Alias command syntax

Hi all,

I want to add a shortcut "xmll" to my .cshrc file. By using "xmll" I want the following command to be executed:

find . -type f -name 'T*.xml' > xml_list.txt

BUT:

alias xmll 'find . -type f -name 'T*.xml' > xml_list.txt'

doesn't work.

What is the correct syntax?

Thank you!

Do you think , the below command is correct?

find . -type f -name 'T*.xml' > xml_list.txt

"*" will not expand if u are putting it in a " ' " single quote.

refer :

http://stackoverflow.com/questions/1250079/bash-escaping-single-quotes-inside-of-single-quoted-strings#1250279
1 Like

I do. find evaluates * for -name and -path. It wouldn't make sense to put the * outside quotes -- how could the shell expand filenames find hasn't found yet?

2 Likes

Notice that you are trying to put single quotes inside single quotes. That's not going to work -- it's going to interpret the second single quote as the end of the first. It sees two quoted sections and an unquoted part, not one quoted section inside another quoted section.

You can't escape things inside single quotes either, so I don't think it's possible to put single quotes inside single quotes.

Try putting the outer expression in double-quotes:

alias xmll "find . -type f -name 'T*.xml' > xml_list.txt"
1 Like

Your goal is

alias xmll

should give

One solution is: put another type of quote characters around the whole line,
see previous post.

1 Like

Thanks! Putting another type of quote characters around the "T*.xml" solved the problem. I tried `T*.xml` before and that didn't work. So I didn't know the solution was so easy. Thanks a lot!

Thanks Corona688.

I was assuming that , if we use 'T*.xml' , it will search for the exact match as "*" can't expand if we put it in single quote.

I was under impression that ,we have to use "T.*xml" instead.

$ find . -name 'T*.xml'
./Too.xml
$ find . -name "T*.xml"
./Too.xml

Thanks again.

Quotes only exist in the mind of the shell. Once the program they are passed to is being run, they are gone. So find gets the same string either way.