# Alias command syntax

**URL:** <https://community.unix.com/t/alias-command-syntax/325027>\
**Category:** Shell Programming and Scripting\
**Created:** [February 28, 2013, 12:02pm UTC](https://community.unix.com/t/alias-command-syntax/325027 "2013-02-28T12:02:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![friend](https://community.unix.com/letter_avatar/friend/32/6_449c533f586939b6e5f246632a46421f.png) [@friend](https://community.unix.com/u/friend)\
**Post date:** [February 28, 2013, 12:02pm UTC](https://community.unix.com/t/alias-command-syntax/325027/1 "2013-02-28T12:02:57Z")

</div>

Hi all,

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

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

```

BUT:

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

```

doesn't work.

What is the correct syntax?

Thank you!

---

<div class="post-metadata">

**Author:** ![panyam](https://community.unix.com/letter_avatar/panyam/32/6_449c533f586939b6e5f246632a46421f.png) [@panyam](https://community.unix.com/u/panyam)\
**Post date:** [February 28, 2013, 12:16pm UTC](https://community.unix.com/t/alias-command-syntax/325027/2 "2013-02-28T12:16:16Z")

</div>

Do you think , the below command is correct?

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

```

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

refer :

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

```

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [February 28, 2013, 12:43pm UTC](https://community.unix.com/t/alias-command-syntax/325027/3 "2013-02-28T12:43:03Z")

</div>

> [@panyam](#):
>
> Do you think , the below command is correct?

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?

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [February 28, 2013, 12:46pm UTC](https://community.unix.com/t/alias-command-syntax/325027/4 "2013-02-28T12:46:24Z")

</div>

> [@](#):
>
> ```plaintext
> alias xmll 'find . -type f -name 'T*.xml' > xml_list.txt'
> 
> ```

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:

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

```

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_449c533f586939b6e5f246632a46421f.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [February 28, 2013, 1:06pm UTC](https://community.unix.com/t/alias-command-syntax/325027/5 "2013-02-28T13:06:12Z")

</div>

Your goal is

```plaintext
alias xmll

```

should give

> [@](#):
>
> find . -type f -name 'T\*.xml' \> xml\_list.txt

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

---

<div class="post-metadata">

**Author:** ![friend](https://community.unix.com/letter_avatar/friend/32/6_449c533f586939b6e5f246632a46421f.png) [@friend](https://community.unix.com/u/friend)\
**Post date:** [March 1, 2013, 4:21am UTC](https://community.unix.com/t/alias-command-syntax/325027/6 "2013-03-01T04:21:42Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![panyam](https://community.unix.com/letter_avatar/panyam/32/6_449c533f586939b6e5f246632a46421f.png) [@panyam](https://community.unix.com/u/panyam)\
**Post date:** [March 1, 2013, 4:32am UTC](https://community.unix.com/t/alias-command-syntax/325027/7 "2013-03-01T04:32:30Z")

</div>

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.

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

```

Thanks again.

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [March 4, 2013, 1:34pm UTC](https://community.unix.com/t/alias-command-syntax/325027/8 "2013-03-04T13:34:39Z")

</div>

> [@panyam](#):
>
> 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.

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.
