Tip: How to Place Pause in Bash Scripts
There some scripts that need human interaction from time to time from confirming certain actions or to warn users that they are about to do something stupid ( “ rm -rf / “, perhaps?). In any case, putting a pause break in a Bash script is a very nifty trick to learn.
This is an example of how to use the Bash built-in command read to put pauses in scripts:
#!/bin/bash
find /home -type f -name "*.txt"
read -p "Press [enter] key to delete *.txt files in /home or CTRL+C to exit"
find /home -type f -name "*.txt" | xargs rm -v
This example script will run the find command and display the results. If user presses the Enter key, the script will remove all files that were found, while pressing CTRL+C will terminate the script.
Here is another variation of the the script:
#!/bin/bash
find /home -type f -name "*.txt"
echo "Press [enter] key to delete *.txt files in /home or CTRL+C to exit"
read contscr
find /home -type f -name "*.txt" | xargs rm -v
Tip: Remove Long List of Files
How to delete long list of files in Linux?
Let’s say you have a long list of files that you want to delete and simply running rm -fv * just won’t work and Linux will let you know by giving you this error:
Argument list too long.
When you get this error, it means that the number of files is too many for the kernel to process.
There is a simple workaround for this.
read more
Tip: How to Delete Files with Special Characters
How to delete files with dash or any special character?
Have you tried to delete a who-knows-where-it-came-from file which has a special character like preceded with dash or question mark? I bet that when you tried to delete it, you got something like this:
read more
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- smeaferrepove on Howto: Install yum On RHEL 4
- Anidich1 on Tip: Add User and Generate Password Script
- Tom S on Cebu Pacific Sucks
- kadersardar on PinoyTux Spreads Some CommentLuv
- Steve on Creative Labs Threatens Third Party Driver Modder








