The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

simple shell script, ls while loop, can't use a file

MadpandaMadpanda suburbs west of chicagoRegistered User regular
edited May 2012 in Help / Advice Forum
Trying to create a simple shell script which will do something like

while 1 (i want to create an infinite loop until broken out of)
ls -ltr filename*
sleep 100

I need to run this from a linux command line and can't read from a file. I thought there was a way to do this but I haven't been able to get it working.

camo_sig2.png
Steam/PSN/XBL/Minecraft / LoL / - Benevicious | WoW - Duckwood - Rajhek
Madpanda on

Posts

  • grouch993grouch993 Both a man and a numberRegistered User regular
    quote the regular expression so the shell doesn't try to interpret the asterisk. Some shells use back ticks to force a command to run.

    `ls -ltr "filename*"`

    Do you want to assign the results to a variable or something to be able to test results?

    Steam Profile Origin grouchiy
  • MadpandaMadpanda suburbs west of chicagoRegistered User regular
    edited May 2012
    Nope i just want to be able to run ls -ltr file* and have it output to terminal every minute or so, without putting an actual shell script on the machine.

    Madpanda on
    camo_sig2.png
    Steam/PSN/XBL/Minecraft / LoL / - Benevicious | WoW - Duckwood - Rajhek
  • shwaipshwaip Registered User regular
    edited May 2012
    while true; do ls filename*; sleep 100; done

    from:
    http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html

    shwaip on
  • notmetalenoughnotmetalenough Registered User regular
    Madpanda wrote: »
    Nope i just want to be able to run ls -ltr file* and have it output to terminal every minute or so, without putting an actual shell script on the machine.

    Or you could use watch.
    http://ss64.com/bash/watch.html

    Samael the Radiant Faced-- Official Naming, Going Nuclear, Click on the Quest, Make She Run and Guild Measurements Officer - Clawshrimp & Co, Draenor-US
Sign In or Register to comment.