LinuxQuestions.org
Help answer threads with 0 replies.
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 01-05-2013, 04:26 AM   #1
windbadboy
LQ Newbie
 
Registered: Jul 2009
Posts: 25

Rep: Reputation: 0
display a file named aab


I created a file named 'aab',and execute the following order:
[root@cu home]# ls a\{2\}b
ls: a{2}b: No such file or directory

I want the result is to display the aab file,but it doesn't work,how to get the result what I want.
 
Old 01-05-2013, 04:29 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

How about
Code:
ls aab
Or do you refer to something else, for example the contents of the file? That would be one of the following
Code:
cat aab
less aab
more aab
Not quite sure why you add the { } to the file name if you didn't include them in it when creating the file.

Kind regards,

Eric
 
Old 01-05-2013, 05:01 AM   #3
windbadboy
LQ Newbie
 
Registered: Jul 2009
Posts: 25

Original Poster
Rep: Reputation: 0
thanks in advance.
I know your way is ok,but I want to display it with RE.
 
Old 01-05-2013, 05:18 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

Do you mean something like this for example:
Code:
ls [a]*b
which would find all files beginning with any number of character 'a' followed by b? Remember that it's not 'ls' that's doing the globbing but bash.

Kind regards,

Eric
 
Old 01-05-2013, 09:11 AM   #5
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 592

Rep: Reputation: 140Reputation: 140
Bash only supports globbing and if you enable it extended globbing, If you want to use RE you have to use find.
 
Old 01-05-2013, 09:14 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Quote:
Originally Posted by whizje View Post
Bash only supports globbing and if you enable it extended globbing, If you want to use RE you have to use find.
Hi,

Or use 'ls' and pipe the output to a program that can use regular expressions, for example grep. Just mentioning but find is a lot more powerful, I agree.

Kind regards,

Eric
 
Old 01-05-2013, 11:44 AM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,013

Rep: Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225
Quote:
Originally Posted by windbadboy View Post
I know your way is ok,but I want to display it with RE.
Maybe you should ask about what you really want to do.
 
Old 01-05-2013, 05:33 PM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You may also consider the extglob shell option:
Code:
$ touch aab aaab aaaab
$ ls @(a)@(a)b
bash: syntax error near unexpected token `('
$ shopt -s extglob
$ ls @(a)@(a)b
aab
$ ls @(a)@(a)@(a)b
aaab
$ ls *@(a)@(a)b
aaaab  aaab  aab
$
See
Code:
man -P "less -p extglob" bash
or http://www.gnu.org/software/bash/man...ttern-Matching for details.
 
1 members found this post helpful.
  


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] SOLUTION: named: loading from master file managed-keys.bind failed: file not found catkin Linux - Server 2 11-08-2011 03:51 PM
(bind) named: couldn't open pid file '/var/run/named/named.pid' - any help? samengr Linux - Server 6 04-01-2009 07:22 AM
file /var/lib/named/var/named/reverse/named.zero failed: file not found Toadman Linux - Software 15 03-18-2009 08:01 PM
service named cant start error in named.conf file gayanasa Linux - Server 2 07-02-2008 10:58 AM
chown -R named:named /var/named crash the system? joangopan Fedora 2 09-09-2007 03:46 AM


All times are GMT -5. The time now is 11:50 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