Trying to setup alias but getting error

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to setup alias but getting error
# 1  
Old 08-15-2011
Trying to setup alias but getting error

Hi All,

I am trying to setup an Alias but it's not working properly. Can someone please help ?
alias lx='ls -lat | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}


Last edited by Scott; 08-15-2011 at 06:34 AM.. Reason: Code tags
# 2  
Old 08-15-2011
You need to escape your awk single quotes
alias lx='ls -lat | awk '\''{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}'\'''

Last edited by Scott; 08-15-2011 at 06:35 AM.. Reason: Code tags
# 3  
Old 08-15-2011
it is better to write a shell function instead.
# 4  
Old 08-19-2011
Thanks! I really appreciate your help. I will consider using functions next time as stated above.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Alias help

I am creating subversion pre commit hook on linux to run on client side but its not working and throwing an error - alias svnbi="plutil *.plist|grep -v OK; if ; then svn ci -m $1 ; fi" but when I run - (test is $1 here) svnbi test bash: syntax error near unexpected token `test' ... (1 Reply)
Discussion started by: jacki
1 Replies

2. UNIX for Dummies Questions & Answers

IP Alias

Quick question Have a AIX system that has been up for years with a 192.9.x.x IP scheme and we want to add a second IP to the system. I setup the second IP 10.1.x.x as an alias via smit. Since these two IP's are on different VLANs will this be an issue? Reason I ask is that I cannot ping... (3 Replies)
Discussion started by: Chrisp
3 Replies

3. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

4. UNIX for Dummies Questions & Answers

Find command to exclude directories and setup alias or script?

Hi, Firstly - sorry for the duplicate my other post looked like i was posting a how to for people. But i am wanting some help :P I want to search from / to find files and exclude my mounted ntfs drives. I have found this thread (Which I can't post the URL to until i have 5 posts) it's... (4 Replies)
Discussion started by: mightymouse2045
4 Replies

5. Shell Programming and Scripting

Error while using alias

Hi all, I had set up an alias on CSH. the alias name I am using in a script. when I am using - source scriptName alias name is getting invoked but when I am trying to run same script using - ./scriptName aliasname: command not found error is coming. Any help is appreciated (2 Replies)
Discussion started by: milindb
2 Replies

6. Shell Programming and Scripting

please help me regarding alias

Dear All, I have given alias to run a script which will calculate memory and cpu utilization as "utils" in my bash shell. Even i have given this entry in .profile and .bashrc in my home directory. It is working fine. Now my question is that I want to use this alias in... (17 Replies)
Discussion started by: naree
17 Replies

7. AIX

NIM server setup on etherchannel setup environment

I know that IBM's official stance is that NIM does not work on etherchannel environment, but has anyone able to get around it? I'm working on a p5-590 LPAR system, and the NIM master and clients are all on the same frame. Any help is appreciated. (1 Reply)
Discussion started by: pdtak
1 Replies

8. UNIX for Dummies Questions & Answers

Alias Help

Can someone help me with an alias...? (1 Reply)
Discussion started by: NetJones
1 Replies

9. UNIX for Advanced & Expert Users

Alias database error

I am running Postfix 2.3 on FreeBSd 6.1 everytime I use the postalias command I get this error message that says no mapping in /etc/mail/mailer.conf hash database is installed and that is what is uncommented out in my file in the mailer.conf file everthing is pointing ... (0 Replies)
Discussion started by: rbizzell
0 Replies

10. HP-UX

alias help

i want to use short cut alias command but its not happening can any on help (4 Replies)
Discussion started by: shafique
4 Replies
Login or Register to Ask a Question