Avatar of jbaird123
jbaird123
 asked on

Unix "ls" command: How to display only certain files using the ls command

Can someone tell me what syntax to use in order to list only files matching a certain pattern using the "ls" command in Unix?

I'm trying to use this:

ls -l scea*

I was hoping this would display only files beginning with the 4 characters "scea", but it is not working.
Unix OSLinux

Avatar of undefined
Last Comment
jbaird123

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
woolmilkporc

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jbaird123

ASKER
It seems that this works on one unix box, but not on another.  Here is what I am getting:

ls: scea*: No such file or directory
woolmilkporc

Ok,

so there is no such file or directory on the other box!

Cross-check with

echo scea*

If the only output is

scea*

there is indeed nothing which starts with scea
jbaird123

ASKER
It's very strange.  echo scea* returns nothing, but simply typing "ls" returns a lot of files many of which begin with scea.  It seems that if I try to use a format mask of any kind for any file, nothing gets returned.  But there are definitely files in that directory that match the mask - I can see them when I run "ls" with no mask.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
woolmilkporc

OK,

so it seems that in your shell the "noglob" option is in effect.

With this option file name expansion ("globbing") is inhibited.

Which is your shell? ("echo $0")

Issue "set -o" to see all the options.

If "noglob" is indeed "on" and if your shell is ksh or bash issue "set +o noglob" and retry.

If it works now you'll have to find out where this option is being set.
Depending on your shell this could be $HOME/.profile, /etc/profile, $HOME/.bashrc and so on.

wmp
jbaird123

ASKER
I'm not sure I understand.  I entered this command:

echo $0

Then I just get this output;

$0

Any ideas?
woolmilkporc

What about "set -o" and noglob?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
woolmilkporc

"echo $0" should have displayed the name of your shell. Does "echo $SHELL" work?

wmp
ozo

what shell are you running on the other unix box?
jbaird123

ASKER
It looks like "set -o" works fine on the "good" machine.  When I run it on the "bad" machine, I get this:

Cannot run program "set" (in directory "/")
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
omarfarid

what unix or linux are you running? can you post outcome of the commands below

uname -a
id
ps
Ringthane

Try this" grep <username> /etc/passwd" and tell me what it returns

<username> is of course your loginname
jbaird123

ASKER
omarfarid:

Here is the output:

Command: uname -a
root
Linux mplhprht 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

Command: id
root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:java_t:SystemLow-SystemHigh
Command: ps
root
  PID TTY          TIME CMD
    1 ?        00:03:32 init
    2 ?        00:00:03 migration/0
    3 ?        00:00:00 ksoftirqd/0
    4 ?        00:00:00 watchdog/0
    5 ?        00:00:03 migration/1
    6 ?        00:00:00 ksoftirqd/1
    7 ?        00:00:00 watchdog/1
    8 ?        00:00:00 migration/2
    9 ?        00:00:00 ksoftirqd/2
   10 ?        00:00:00 watchdog/2
   11 ?        00:00:00 migration/3
   12 ?        00:00:00 ksoftirqd/3
   13 ?        00:00:00 watchdog/3
   14 ?        00:00:00 migration/4
   15 ?        00:00:00 ksoftirqd/4
   16 ?        00:00:00 watchdog/4
   17 ?        00:00:00 migration/5
   18 ?        00:00:00 ksoftirqd/5
   19 ?        00:00:00 watchdog/5
   20 ?        00:00:00 migration/6
   21 ?        00:00:00 ksoftirqd/6
   22 ?        00:00:00 watchdog/6
   23 ?        00:00:00 migration/7
   24 ?        00:00:00 ksoftirqd/7
   25 ?        00:00:00 watchdog/7
   26 ?        00:00:00 migration/8
   27 ?        00:00:00 ksoftirqd/8
   28 ?        00:00:00 watchdog/8
   29 ?        00:00:00 migration/9
   30 ?        00:00:00 ksoftirqd/9
   31 ?        00:00:00 watchdog/9
   32 ?        00:00:01 migration/10
   33 ?        00:00:00 ksoftirqd/10
   34 ?        00:00:00 watchdog/10
   35 ?        00:00:01 migration/11
   36 ?        00:00:00 ksoftirqd/11
   37 ?        00:00:00 watchdog/11
   38 ?        00:00:00 migration/12
   39 ?        00:00:00 ksoftirqd/12
   40 ?        00:00:00 watchdog/12
   41 ?        00:00:00 migration/13
   42 ?        00:00:00 ksoftirqd/13
   43 ?        00:00:00 watchdog/13
   44 ?        00:00:00 migration/14
   45 ?        00:00:00 ksoftirqd/14
   46 ?        00:00:00 watchdog/14
   47 ?        00:00:00 migration/15
   48 ?        00:00:00 ksoftirqd/15
   49 ?        00:00:00 watchdog/15
   50 ?        00:00:00 events/0
   51 ?        00:00:00 events/1
   52 ?        00:00:00 events/2
   53 ?        00:00:00 events/3
   54 ?        00:00:00 events/4
   55 ?        00:00:00 events/5
   56 ?        00:00:00 events/6
   57 ?        00:00:00 events/7
   58 ?        00:00:00 events/8
   59 ?        00:00:00 events/9
   60 ?        00:00:00 events/10
   61 ?        00:00:00 events/11
   62 ?        00:00:00 events/12
   63 ?        00:00:00 events/13
   64 ?        00:00:00 events/14
   65 ?        00:00:00 events/15
   66 ?        00:00:00 khelper
  263 ?        00:00:00 kthread
  283 ?        00:00:00 kblockd/0
  284 ?        00:00:00 kblockd/1
  285 ?        00:00:00 kblockd/2
  286 ?        00:00:00 kblockd/3
  287 ?        00:00:00 kblockd/4
  288 ?        00:00:00 kblockd/5
  289 ?        00:00:00 kblockd/6
  290 ?        00:00:00 kblockd/7
  291 ?        00:00:00 kblockd/8
  292 ?        00:00:00 kblockd/9
  293 ?        00:00:00 kblockd/10
  294 ?        00:00:00 kblockd/11
  295 ?        00:00:00 kblockd/12
  296 ?        00:00:00 kblockd/13
  297 ?        00:00:00 kblockd/14
  298 ?        00:00:00 kblockd/15
  299 ?        00:00:00 kacpid
  441 ?        00:00:00 cqueue/0
  442 ?        00:00:00 cqueue/1
  443 ?        00:00:00 cqueue/2
  444 ?        00:00:00 cqueue/3
  445 ?        00:00:00 cqueue/4
  446 ?        00:00:00 cqueue/5
  447 ?        00:00:00 cqueue/6
  448 ?        00:00:00 cqueue/7
  449 ?        00:00:00 cqueue/8
  450 ?        00:00:00 cqueue/9
  451 ?        00:00:00 cqueue/10
  452 ?        00:00:00 cqueue/11
  453 ?        00:00:00 cqueue/12
  454 ?        00:00:00 cqueue/13
  455 ?        00:00:00 cqueue/14
  456 ?        00:00:00 cqueue/15
  459 ?        00:00:00 khubd
  461 ?        00:00:00 kseriod
  650 ?        00:00:02 kswapd0
  651 ?        00:00:01 kswapd1
  652 ?        00:00:00 aio/0
  653 ?        00:00:00 aio/1
  654 ?        00:00:00 aio/2
  655 ?        00:00:00 aio/3
  656 ?        00:00:00 aio/4
  657 ?        00:00:00 aio/5
  658 ?        00:00:00 aio/6
  659 ?        00:00:00 aio/7
  660 ?        00:00:00 aio/8
  661 ?        00:00:00 aio/9
  662 ?        00:00:00 aio/10
  663 ?        00:00:00 aio/11
  664 ?        00:00:00 aio/12
  665 ?        00:00:00 aio/13
  666 ?        00:00:00 aio/14
  667 ?        00:00:00 aio/15
  825 ?        00:00:00 kpsmoused
  969 ?        00:00:00 cciss_scan00
  987 ?        00:00:00 ata/0
  988 ?        00:00:32 ata/1
  989 ?        00:01:30 ata/2
  990 ?        00:00:14 ata/3
  991 ?        00:00:39 ata/4
  992 ?        00:00:02 ata/5
  993 ?        00:00:08 ata/6
  994 ?        00:00:00 ata/7
  995 ?        00:00:00 ata/8
  996 ?        00:07:14 ata/9
  997 ?        00:14:06 ata/10
  998 ?        00:02:48 ata/11
  999 ?        00:06:42 ata/12
 1000 ?        00:00:31 ata/13
 1001 ?        00:01:43 ata/14
 1002 ?        00:00:02 ata/15
 1003 ?        00:00:00 ata_aux
 1021 ?        02:06:59 scsi_eh_0
 1022 ?        00:00:00 scsi_eh_1
 1040 ?        00:00:00 kstriped
 1109 ?        00:00:00 ksnapd
 1180 ?        00:00:02 kjournald
 1210 ?        00:00:10 kauditd
 1243 ?        00:00:02 udevd
 2411 ?        00:00:00 scsi_eh_2
 2565 ?        00:00:00 qla2xxx_2_dpc
 2566 ?        00:00:00 scsi_wq_2
 2568 ?        00:00:00 fc_wq_2
 2569 ?        00:00:00 fc_dl_2
 2637 ?        00:00:00 scsi_eh_3
 3142 ?        00:00:00 qla2xxx_3_dpc
 3144 ?        00:00:00 scsi_wq_3
 3145 ?        00:00:00 fc_wq_3
 3146 ?        00:00:00 fc_dl_3
 8325 ?        00:00:08 crond
 8797 ?        00:00:52 avagent.bin
 9603 ?        00:00:00 kmpathd/0
 9604 ?        00:00:00 kmpathd/1
 9605 ?        00:00:00 kmpathd/2
 9606 ?        00:00:00 kmpathd/3
 9607 ?        00:00:00 kmpathd/4
 9608 ?        00:00:00 kmpathd/5
 9609 ?        00:00:00 kmpathd/6
 9610 ?        00:00:00 kmpathd/7
 9611 ?        00:00:00 kmpathd/8
 9612 ?        00:00:00 kmpathd/9
 9613 ?        00:00:00 kmpathd/10
 9614 ?        00:00:00 kmpathd/11
 9615 ?        00:00:00 kmpathd/12
 9616 ?        00:00:00 kmpathd/13
 9617 ?        00:00:00 kmpathd/14
 9619 ?        00:00:00 kmpathd/15
 9620 ?        00:00:00 kmpath_handlerd
 9646 ?        00:07:08 kjournald
 9649 ?        00:00:35 kjournald
 9656 ?        00:01:51 kjournald
 9658 ?        00:00:00 kjournald
10135 ?        00:00:00 iscsi_eh
10331 ?        00:00:00 scsi_eh_4
10333 ?        00:00:00 scsi_wq_4
10337 ?        00:00:00 scsi_eh_5
10340 ?        00:00:00 scsi_wq_5
10384 ?        00:00:00 ib_addr
10445 ?        00:00:00 ib_mcast
10446 ?        00:00:00 ib_inform
10447 ?        00:00:00 local_sa
10465 ?        00:00:00 iw_cm_wq
10483 ?        00:00:00 ib_cm/0
10484 ?        00:00:00 ib_cm/1
10485 ?        00:00:00 ib_cm/2
10486 ?        00:00:00 ib_cm/3
10487 ?        00:00:00 ib_cm/4
10488 ?        00:00:00 ib_cm/5
10489 ?        00:00:00 ib_cm/6
10490 ?        00:00:00 ib_cm/7
10491 ?        00:00:00 ib_cm/8
10492 ?        00:00:00 ib_cm/9
10493 ?        00:00:00 ib_cm/10
10494 ?        00:00:00 ib_cm/11
10495 ?        00:00:00 ib_cm/12
10496 ?        00:00:00 ib_cm/13
10497 ?        00:00:00 ib_cm/14
10498 ?        00:00:00 ib_cm/15
10515 ?        00:00:00 rdma_cm
10539 ?        00:00:00 brcm_iscsiuio
10545 ?        00:00:00 iscsid
10546 ?        00:00:00 iscsid
10956 ?        00:00:11 httpd
11266 ?        00:01:12 auditd
11268 ?        00:00:44 audispd
11289 ?        00:00:00 restorecond
11302 ?        00:00:33 syslogd
11305 ?        00:00:00 klogd
11319 ?        00:03:01 irqbalance
11347 ?        00:00:47 mcstransd
11411 ?        00:00:00 rpciod/0
11412 ?        00:00:00 rpciod/1
11413 ?        00:00:00 rpciod/2
11414 ?        00:00:00 rpciod/3
11415 ?        00:00:00 rpciod/4
11416 ?        00:00:00 rpciod/5
11417 ?        00:00:00 rpciod/6
11418 ?        00:00:00 rpciod/7
11419 ?        00:00:00 rpciod/8
11420 ?        00:00:00 rpciod/9
11421 ?        00:00:00 rpciod/10
11422 ?        00:00:00 rpciod/11
11423 ?        00:00:00 rpciod/12
11424 ?        00:00:00 rpciod/13
11425 ?        00:00:00 rpciod/14
11426 ?        00:00:00 rpciod/15
11480 ?        00:00:00 rpc.idmapd
11575 ?        1-12:42:40 setroubleshootd
11618 ?        00:00:07 pcscd
11632 ?        00:00:00 acpid
11675 ?        00:00:00 automount
11696 ?        00:00:00 hpiod
11703 ?        00:00:00 python
11720 ?        00:00:32 sshd
11737 ?        00:00:00 xinetd
11775 ?        00:00:36 sendmail
11798 ?        00:00:00 gpm
11878 ?        00:00:00 atd
11905 ?        00:03:13 libvirtd
11919 ?        00:00:01 rhnsd
11989 ?        00:00:00 hald-runner
12103 ?        00:00:00 atd
12106 ?        00:00:00 atd
12112 ?        00:00:00 atd
12113 ?        00:00:00 sh
12114 ?        00:00:00 sh
12116 ?        00:00:00 sh
12117 ?        00:00:00 bash
12118 ?        00:00:00 bash
12119 ?        00:00:00 start_rs.sh
12120 ?        00:00:00 bash
12122 ?        00:04:01 TISEE-linux-gtk
12124 ?        00:18:34 java
12154 ?        00:00:00 bash
12157 ?        00:00:00 java
12190 ?        12:22:54 java
12206 ?        00:00:50 yum-updatesd
12210 ?        00:00:02 gam_server
12218 ?        02:19:57 hald-addon-stor
16194 ?        00:00:00 crond
16195 ?        00:00:00 space.growth
17315 ?        00:00:00 pdflush
17316 ?        00:05:27 pdflush
19741 ?        00:00:04 java
20216 ?        00:00:00 sleep
21693 ?        00:00:00 java
21725 ?        00:00:00 ps

Open in new window

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
jbaird123

ASKER
Ringthane:

Can you tell me what that command is doing before I run it?  It looks like it is searching passwords or something which makes me not want to run it.
jbaird123

ASKER
I am awarding this answer because it addresses my original question.  This thread has turned into sort of a troubleshooting thread for an un-related issue, so I think it's fair to at least award points for the best answer.