Visit Our UNIX and Linux User Community


Alias command syntax


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Alias command syntax
# 1  
Old 02-28-2013
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:

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

BUT:

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

doesn't work.

What is the correct syntax?

Thank you!
# 2  
Old 02-28-2013
Do you think , the below command is correct?

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

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

refer :

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

This User Gave Thanks to panyam For This Post:
# 3  
Old 02-28-2013
Quote:
Originally Posted by 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?
These 2 Users Gave Thanks to Corona688 For This Post:
# 4  
Old 02-28-2013
Quote:
Code:
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:

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

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 02-28-2013
Your goal is
Code:
alias xmll

should give
Quote:
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.
This User Gave Thanks to MadeInGermany For This Post:
# 6  
Old 03-01-2013
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!
# 7  
Old 03-01-2013
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.

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

Thanks again.

Last edited by vbe; 03-01-2013 at 06:49 AM.. Reason: ...

Previous Thread | Next Thread
Test Your Knowledge in Computers #812
Difficulty: Medium
In CSS, the rgba() function define colors using the red-green-blue-accent (RGBA) model.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SUDO help with command alias

Hi there, I'm trying to setup sudo privileges for a user, Oracle in this case, to run Unix commands like mv,chmod, chown, mkdir, rmdir against their own set of commands or scripts. Is there an easier way to do this than to give Unix commands for each of their respective commands as shown below... (2 Replies)
Discussion started by: mbak
2 Replies

2. Shell Programming and Scripting

Alias command help

Hello, I'm attempting to configure shell settings in my new Macbook. The standard unix command line 'alias' doesn't seem to be working: bash-3.2$ alias dir ls -la bash: alias: dir: not found bash: alias: ls: not found bash: alias: -la: not found bash-3.2$ alias dir 'ls -la' bash:... (1 Reply)
Discussion started by: palex
1 Replies

3. UNIX for Dummies Questions & Answers

cp command not working with alias

Hi Friends, I have added some aliases in .bash_profile file under the root folder. Its works fine and very useful, but does not go well with cp command. alias deploy="cd /usr/local/tomcat/webapp" alias artifacts="cd /usr/local/artifacts" but when i try to cp from artifacts folder... (2 Replies)
Discussion started by: prashdeep
2 Replies

4. Shell Programming and Scripting

complicated alias command

hi guys i m making one alias which will set variable , invoke sqlplus and also set prompt of sqlplus,,i have made successfully upto invoking sqlplus in unix but cant pass command in sqlplus here is the command alias sett='export ORACLE_SID=devdb2;sqlplus system/system@test' now this... (3 Replies)
Discussion started by: tapia
3 Replies

5. UNIX for Dummies Questions & Answers

alias command within .profile

Please could someone advise me the command - to set up aliases commands within a .profile using shell sh regards venhart (13 Replies)
Discussion started by: venhart
13 Replies

6. UNIX for Advanced & Expert Users

alias command in script

How can I embed alias command inside the unix script? Script: echo "...." ... ... alias aa=/usr/bin/telnet ... ...The above script is not working. If I type aa hostname in the command prompt 'TELNET' terminal is not opening. Regards,... (2 Replies)
Discussion started by: sharif
2 Replies

7. UNIX for Advanced & Expert Users

Alias a command

Hi 'm executing a java program from my shell script on solaris 9 as $JAVA_HOME\bin\java -ms32m -mx128m -classpath $CLASSPATH com.abc.fwk,abcServer.abcfwkServer $1 & where $1 is port number when i do ps -ef, it shows whole command , i want to give this some alias name as abcProcess, so... (2 Replies)
Discussion started by: b_garima
2 Replies

8. UNIX for Dummies Questions & Answers

a question about alias command

Some Unix systems won't enable you to do the following. What danger do you see lurking in this alias? (a) alias who (b)who -a Do you know it? Thanks! (1 Reply)
Discussion started by: jayyu317
1 Replies

9. UNIX for Advanced & Expert Users

alias for rm command

Hi, i want to make alias for rm command. It should actually move the file to a directory in my home. Say if i type %rm abc.txt the command should expand to %mv abc.txt ~ashishp/trash How should I write the alias for this? -Ashish (8 Replies)
Discussion started by: shriashishpatil
8 Replies

10. UNIX for Dummies Questions & Answers

I want to create a command alias

I want to create a command alias. I know what shell I'm using, I just don't know which file to inter the command alias. When I type "echo $SHELL" the output is as follows: bin/sh If I'm correct, this is the bourne shell. Does anyone know which file to edit in this particular shell? Thanks. (2 Replies)
Discussion started by: cstovall
2 Replies

Featured Tech Videos