1. Download our Official Android App: Forums for Android!

'ls' command and globbing

Discussion in 'Android Devices' started by Mel Blanchard, Apr 15, 2019.

  1. Mel Blanchard

    Mel Blanchard Lurker
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    3
    Joined:
    Apr 15, 2019

    Apr 15, 2019
    3
    1
    16
    Currently running 8.1.0. I want to use globbing with the 'ls' command but keep running into a stone wall. Does globbing not work in Android when using 'ls'?

     

    Advertisement

  2. ocnbrze

    ocnbrze DON'T PANIC!!!!!!!!!
    Rank:
     #13
    Points:
    1,943
    Posts:
    24,395
    Joined:
    May 13, 2010

    May 13, 2010
    24,395
    14,947
    1,943
    Male
    being a flashaholic sponsor, helping others gettin
    los angeles
  3. Mel Blanchard

    Mel Blanchard Lurker
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    3
    Joined:
    Apr 15, 2019

    Apr 15, 2019
    3
    1
    16
    Many thanks. It will take a bit to wade through that but it looks promising.

    Globbing is a tool when running commands that allows a form of filtering the command's output. 'ls' in Ubuntu allows you to use a switch (-I) which when invoked, allows you to exclude display of part of the listing output. In a directory where I have mixed files it allows using a string to avoid displaying all 300 files. I can do it with grep but the extra characters that I have to type '| grep -v <string>' gets old after doing a few hundred times a day. 'ls' in Android does not include the '-I' switch so right now I get to exercise the digits.

    Thanks again.

    Mel
     
    ocnbrze likes this.
  4. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #10
    Points:
    1,988
    Posts:
    8,832
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    8,832
    13,189
    1,988
    Male
    Software developer
    South West of England
    @Mel Blanchard Define a shell function to do your filtering:

    Code (Text):
    1.  
    2. lz() {
    3.    ls -l | grep -v $1
    4. }
    5.  
    Usage:

    Code (Text):
    1.  
    2. lz myfile
    3.  
     
    bcrichster, GameTheory and ocnbrze like this.
  5. Mel Blanchard

    Mel Blanchard Lurker
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    3
    Joined:
    Apr 15, 2019

    Apr 15, 2019
    3
    1
    16
    Thanks LV246. Good solution but the firm's internal policy does not allow adding scripts as the device is treated as a 'record' with privileged information. I am limited to using what tools are stock and available.
     

Nexus 6P

The Nexus 6P is a Huawei made Android Smartphone that would be come the last Nexus device before the launch of Google's Pixel line of phones.

Share This Page

Loading...