LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2010, 10:59 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Rep: Reputation: 32
Question [Bash] How to include quote?


Hello

I've been Googling for this for over half an hour, and still can't get this alias to work :-/

I'd like to add an alias "lld" to only list directories:

Code:
# cat /etc/bash.bashrc
[...]
#BAD alias lld = 'ls -l | egrep '^d''
#BAD alias lld = 'ls -l | egrep \'^d\''
#BAD alias lld = "ls -l | egrep '^d'"
#BAD alias lld = "ls -l | egrep \'^d\'"
#BAD alias lld = "ls -l | egrep '\'^d'\'"
I make sure I log off and log back on, but I'm still getting "No command 'lld' found, did you mean:".

Does someone know how to add an alias that includes a quote, or an alternative to eqrep that doesn't require quotes altogether?

Thank you.
 
Old 08-05-2010, 11:08 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
No spaces seems to work
Code:
fortyfourgalena@desktop1:~$ alias lld='ls -l | egrep '^d''
fortyfourgalena@desktop1:~$ lld
drwxr-xr-x 10 fortyfourgalena fortyfourgalena    4096 2010-06-12 17:20 1_downloads
drwxr-xr-x  2 fortyfourgalena fortyfourgalena    4096 2010-05-29 11:21 2_mail
drwxr-xr-x  2 fortyfourgalena fortyfourgalena    4096 2010-07-28 15:49 3_tax2009_2010
drwxr-xr-x  3 fortyfourgalena fortyfourgalena    4096 2010-03-14 07:42 44galena_website
drwxr-xr-x  3 fortyfourgalena fortyfourgalena    4096 2008-11-11 21:38 botswana2008
drwxr-xr-x  4 fortyfourgalena fortyfourgalena    4096 2008-11-29 16:18 camera test
drwxr-xr-x  7 fortyfourgalena fortyfourgalena    4096 2008-10-21 21:05 car
drwxr-xr-x  2 fortyfourgalena fortyfourgalena    4096 2010-06-15 15:58 Desktop
drwxr-xr-x  4 fortyfourgalena fortyfourgalena    4096 2009-06-08 17:10 documentation
...
...
fortyfourgalena@desktop1:~$ alias lld
alias lld='ls -l | egrep ^d'
fortyfourgalena@desktop1:~$
 
Old 08-05-2010, 11:27 AM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,606

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
Hi,

if you want to avoid the pipe you could also try
Code:
alias lld='ls -ld */' # long listing
alias lld='ls -d */'  # short listing
Also keep Wim's advice in mind about the spaces and '=' sign. There are none.
 
Old 08-06-2010, 06:41 AM   #4
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
Thanks guys. Too bad Bash doesn't say that the error was simply due to its not allowing spaces before/after the "=" sign :-/

The "-d" option is not exactly was I need, since it not only displays directories but also symlinks.
 
Old 08-06-2010, 08:30 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Works without quotes:

alias lld='ls -l | grep ^d'
 
Old 08-07-2010, 01:36 AM   #6
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by MTK358 View Post
Works without quotes:
I didn't try Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] escaping a single quote from a bash script atbrew Programming 8 07-21-2010 10:21 AM
sed : Convert double quote to singe quote pgb_710 Programming 6 01-21-2010 08:59 AM
when to quote or not to quote variable names - mktemp problem glinux Linux - Newbie 3 02-20-2009 05:37 PM
how to use single quote in bash shell like: echo ''\''' linuxtyh Linux - General 6 12-12-2008 12:56 AM
Bash commands not include??? fxlee Linux - Newbie 4 10-26-2001 11:51 PM


All times are GMT -5. The time now is 05:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration