I would like to use the rm command such that it returns an error when there is a separate asterisk in its argument. For example, if I type rm -f * .txt , then this command should not be executed (this way I have already removed several files unintentionally). Could you please help me what the simplest way is to do this?
Aliasing the rm command to avoid evaluating separate asterisks
54 Views Asked by AudioBubble At
1
There are 1 best solutions below
Related Questions in BASH
- When does Bash read heredocs?
- Why `set -o pipefail` gives different output even though the pipe is not failing
- Run an external command within jq to manipulate each values of a particular key
- API key 401 error in .env.development file
- How to "Enable mobile data" on a Huawei E3372 4G USB dongle using a bash script in Windows
- ImageMagick / Bash : pipe ignored(?) when filename format variable used
- MacOS Bash-Script: while read p and echo
- Parse command line arguments and write useful usage message without additional code
- JQ JSON - Values to Array
- why variable substitution is so different?
- postbank_pdf2csv: how to setup with Cygwin in Windows?
- Custom Bash functions & custom statements - Need some advice
- unexpected operator == in square brackets when trying to use gum lib
- How to disable a bash builtin inside a docker container
- Use sed or rename find series of alphabet then replace with with the same alphabet and a dash -
Related Questions in SHELL
- macOS - Most secure way of a GUI SUDO_ASKPASS
- When does Bash read heredocs?
- Why `set -o pipefail` gives different output even though the pipe is not failing
- Run multiple shell scripts in Dockerfile
- Alias does not take effect when I use Vim to execute external commands
- why variable substitution is so different?
- Error: fish: ${ is not a valid variable in fish
- Custom Bash functions & custom statements - Need some advice
- unexpected operator == in square brackets when trying to use gum lib
- Delete first three lines containing a certain word
- Keep the log for the last 14 days
- Iterate over items in one array and groups of items in second array
- Keep multi-version of a static-lib like what we do for shared-libs
- How to write function in bash for reuse shell commands inside using osascript?
- Why is it that when I pass certain directory names to `ls`, sometimes it does not list their contents?
Related Questions in ALIAS
- How do I separate emails (from 1 alias) in Thunderbird from invasive websites on Firefox with file browsing scripts? Should I worry?
- Using Aliases in a Javascript Function
- Python unexpected non-zero returncode when checking alias command set in .bashrc file
- Creating aliases for Github Copilot CLI (ghcs, ghce not recognised)
- procedure/alias [a portion of] a somewhat long MySQL command?
- Understanding class importation and alias management in Laravel 11's new directory structure
- Drupal 9 contextual filter on url alias
- How to access the previous value of text in Cypress that you expect to change?
- How to time how long a bash alias took to execute (solved... maybe?)
- SQL query in Oracle to sum up values from an alias column
- Microsoft GraphAPI - behavior with emails received from alias email addresses
- How to Alias `python` to Python 2 (`/usr/bin/python2`) on WSL Ubuntu?
- How do I tell the Jackson JSON deserializer to prefer one field over another when both are present?
- Replace dataframe with its alias in select in pyspark
- Error: vite build in github actions - for using aliases
Related Questions in RM
- Is there any way I can use rm -rf in PowerShell?
- nodejs fs.rm(path, { recursive: true, force: true }) throws "ENOTEMPTY: directory not empty"
- node js rimraf delete dist folder in any of the subfolders of src
- rm: cannot remove `dir-name': Directory not empty
- Delete multiple shortcuts on macOS
- Deleting folders and files from s3 bucket based on last modified date column and based on name prefix using AWS CLI
- Shell script - rm does not remove directory from variable set by external parameter
- Add-AzureRmVhd : Resource group 'ResourceGroupName' could not be found
- How to remove special character filename in Linux?
- Rightmove deliveryPointId does not match up with Royal Mail "CSV PAF.CSV" file
- How to rename or remove file name with weird quotes and slashes in linux
- Mac terminal directory issues
- Remove all files in *that* directory except *these* files - dangerous in remote directory?
- Aliasing the rm command to avoid evaluating separate asterisks
- failed to delete multiple folders inside one folder except 3 folders using rm
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
As discussed in comments, there is normally no way for an
rmalias or function to detect if it was run with a*that was expanded by the shell to a list of arguments. This Bash function demonstrates a possible alternative way to help with your problem:-etest. For instance, if run withrm * .txtit will delete nothing because it will detect a non-existing.txtfile.rmon the full list of arguments.