Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8805279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:49:36+00:00 2026-06-14T01:49:36+00:00

In ~/.bash_aliases I want to create an alias for repeat word that will repeat

  • 0

In ~/.bash_aliases I want to create an alias for repeat word that will repeat given command n times.

repeat() {
    n=$1
    shift
    while [ $(( n -= 1 )) -ge 0 ]
    do
        "$@"
    done
}

I want to use repeat to list updated files in a directory so I made following function (WAIT,CLEAR,LIST):

wcls() {
    m=$1
    shift
    clear
    date
    ls -l "$@"
    sleep $m
}

I have a folder where are my_file1 and my_file2.
If I run the script :

repeat 500 wcls 2 my_file*

i get

my_file1 ...
my_file2 ...

and in the mean time I change my_file2 to my_file3 the script wont update the contents showing

my_file1 ...
my_file2 no such file or directory

what should I do for my functions to correctly handle asterisks?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:49:37+00:00Added an answer on June 14, 2026 at 1:49 am

    The problem here is that your asterisks are being expanded by the interactive shell. When you execute the alias, you feed it a list of files, not a filespec with an asterisk.

    I don’t think there’s an easy way around this, other than by escaping your asterisks and letting the alias do the expansion. Which is a bad idea, because then filenames with funny characters could affect what’s being executed merely by their existence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In bash, I can use the script command, which dumps everything that shows on
I want to run a command as a not-root user in a startup script
I want to create bash aliases within a loop where the loop is reading
In bash you can give a command an alias like so: alias e=echoset alias
I want to set an alias to my installation of firefox so I can
How do I pass the command line arguments to an alias? Here is a
Is there a way to expand a bash alias on the command-line and get
Is there a way to define aliases so that shell-command can recognize them? shell
My bash-script looks as following: echo "Description:" while [ $finishInput -eq 0 ]; do
I have a shell script which I want to run without using the sh

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.