Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: ls comand

  1. #11
    Join Date
    Dec 2008
    Location
    Northwest Ohio
    Beans
    1,581
    Distro
    Lubuntu 13.10 Saucy Salamander

    Re: ls comand

    Quote Originally Posted by Copper Bezel View Post
    ankspo71, ls ignores hidden files unless you tell it not to, with -a. Now, that said, if I run

    Code:
    ls -a | grep -i x
    I get every file that includes an x or an X, naturally. But that means that adding an asterisk, like *x, doesn't mean anything, because anything you drop into grep is assumed to be a part of a string - grep x actually means grep *x* already.
    Hi, and thanks.
    The ls & grep commands I posted above no longer work for me 30 minutes after posting them (I tested them several times as I posted them too), and neither do any of the examples given by matt_symes. I think maybe I didn't make a typo after all... instead I must be encountering some odd bugs because I'm using Natty Beta. The <find /home/user -iname '*x'> command still works for me though.

  2. #12
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: ls comand

    Hi

    Quote Originally Posted by ankspo71 View Post
    Hi, and thanks.
    The ls & grep commands I posted above no longer work for me 30 minutes after posting them (I tested them several times as I posted them too), and neither do any of the examples given by matt_symes. I think maybe I didn't make a typo after all... instead I must be encountering some odd bugs because I'm using Natty Beta. The <find /home/user -iname '*x'> command still works for me though.
    That's really odd. Can you post sample output ?

    That's the good thing about Linux though; always more than one way to do things

    Kind regards
    Last edited by matt_symes; April 3rd, 2011 at 12:36 AM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  3. #13
    Join Date
    Dec 2008
    Location
    Northwest Ohio
    Beans
    1,581
    Distro
    Lubuntu 13.10 Saucy Salamander

    Re: ls comand

    Quote Originally Posted by matt_symes View Post
    Hi
    That's really odd. Can you post sample output ?
    That's the good thing about Linux though; always more than one way to do things
    Kind regards
    Sure can.

    Code:
    james@Kubuntu-Natty:~$ ls | grep x
    adcx.txt
    test.123x
    tux
    txa
    xero
    xyz
    james@Kubuntu-Natty:~$ ls /home/james/x?
    ls: cannot access /home/james/x?: No such file or directory
    james@Kubuntu-Natty:~$ ls /home/james/ux?
    ls: cannot access /home/james/ux?: No such file or directory
    james@Kubuntu-Natty:~$ ls /home/james/?ux
    james@Kubuntu-Natty:~$ ls /home/james/*ux
    james@Kubuntu-Natty:~$ ls /home/james/*x
    /home/james/test.123x
    /home/james/tux:
    james@Kubuntu-Natty:~$ ls /home/james/?x
    ls: cannot access /home/james/?x: No such file or directory
    james@Kubuntu-Natty:~$ ls ~/?ux
    james@Kubuntu-Natty:~$ ls ~/?x
    ls: cannot access /home/james/?x: No such file or directory
    james@Kubuntu-Natty:~$ ls ~/*ux
    james@Kubuntu-Natty:~$ ls ~/*ux*
    james@Kubuntu-Natty:~$ ls ~/ux?
    ls: cannot access /home/james/ux?: No such file or directory
    james@Kubuntu-Natty:~$ ls ~/*x
    /home/james/test.123x
    /home/james/tux:

  4. #14
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: ls comand

    Hi

    Code:
    matthew@matthew-laptop:~$ ls /bin
    bash     bzfgrep       chown                 dbus-uuidgen   ed          gzexe     lesskey   mktemp      nc.openbsd        openvt    rm          sleep      touch            ypdomainname  zmore
    bsd-csh  bzgrep        chvt                  dd             egrep       gzip      lesspipe  more        netcat            pidof     rmdir       static-sh  true             zcat          znew
    bunzip2  bzip2         cp                    df             false       hostname  ln        mount       netstat           ping      rnano       stty       ulockmgr_server  zcmp
    busybox  bzip2recover  cpio                  dir            fgconsole   ip        loadkeys  mountpoint  nisdomainname     ping6     run-parts   su         umount           zdiff
    bzcat    bzless        csh                   dmesg          fgrep       kbd_mode  login     mt          ntfs-3g           plymouth  sed         sync       uname            zegrep
    bzcmp    bzmore        dash                  dnsdomainname  fuser       kill      ls        mt-gnu      ntfs-3g.probe     ps        setfont     tailf      uncompress       zfgrep
    bzdiff   cat           date                  domainname     fusermount  less      lsmod     mv          ntfs-3g.secaudit  pwd       setupcon    tar        unicode_start    zforce
    bzegrep  chgrp         dbus-cleanup-sockets  dumpkeys       grep        lessecho  mkdir     nano        ntfs-3g.usermap   rbash     sh          tcsh       vdir             zgrep
    bzexe    chmod         dbus-daemon           echo           gunzip      lessfile  mknod     nc          open              readlink  sh.distrib  tempfile   which            zless
    matthew@matthew-laptop:~$ ls /bin/*r
    /bin/bzip2recover  /bin/dir  /bin/fuser  /bin/mkdir  /bin/rmdir  /bin/tar  /bin/ulockmgr_server  /bin/vdir
    matthew@matthew-laptop:~$ 
    matthew@matthew-laptop:~$ ls /bin/g*p
    /bin/grep  /bin/gunzip  /bin/gzip
    matthew@matthew-laptop:~$
    matthew@matthew-laptop:~$ ls /bin/nt*g?*
    /bin/ntfs-3g.probe  /bin/ntfs-3g.secaudit  /bin/ntfs-3g.usermap
    matthew@matthew-laptop:~$ ls /bin/nt*g?p*
    /bin/ntfs-3g.probe
    matthew@matthew-laptop:~$
    matthew@matthew-laptop:~$ ls /bin/z??r*p
    /bin/zegrep  /bin/zfgrep
    matthew@matthew-laptop:~$ ls /bin/?a?
    /bin/cat  /bin/tar
    matthew@matthew-laptop:~$
    As you say, maybe a bug in natty ?

    Kind regards.
    Last edited by matt_symes; April 3rd, 2011 at 01:39 AM. Reason: Typo
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  5. #15
    Join Date
    Dec 2008
    Location
    Northwest Ohio
    Beans
    1,581
    Distro
    Lubuntu 13.10 Saucy Salamander

    Re: ls comand

    Hi Again.
    Okay, your command examples are working as expected again. I rebooted and everything is working better than it was before. I think I have found my mistake for my ls & grep command too, and that it requires 2 or more characters when using wildcards with grep.
    Code:
    james@Kubuntu-Natty:~$ ls | grep x
    adcx.txt
    test.123x
    tux
    txa
    xero
    xyz
    james@Kubuntu-Natty:~$ ls | grep *x
    <no output>
    james@Kubuntu-Natty:~$ ls | grep ux
    tux
    james@Kubuntu-Natty:~$ ls | grep *ux
    tux
    james@Kubuntu-Natty:~$ ls | grep 23x
    test.123x
    james@Kubuntu-Natty:~$ ls | grep *23x
    test.123x
    james@Kubuntu-Natty:~$ ls /home/james | grep *ux
    tux
    But as someone said the * isn't necessary anyways.
    Last edited by ankspo71; April 3rd, 2011 at 01:54 AM.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •