Comments on: 5 Useful Shell Scripts for Linux Newbies – Part II https://www.tecmint.com/basic-shell-programming-part-ii/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Thu, 01 Feb 2024 04:50:59 +0000 hourly 1 By: Ravi Saive https://www.tecmint.com/basic-shell-programming-part-ii/comment-page-1/#comment-2131404 Thu, 01 Feb 2024 04:50:59 +0000 http://www.tecmint.com/?p=3500#comment-2131404 In reply to Pete.

@Pete,

I have modified a script and included a confirmation prompt, where the script will only proceed with deleting the original file if the user enters 'y' for yes. If 'n' or any other input is provided, the script will exit without removing the file.

This helps prevent accidental deletions and provides a safer user experience.

]]>
By: Pete https://www.tecmint.com/basic-shell-programming-part-ii/comment-page-1/#comment-2131297 Wed, 31 Jan 2024 18:23:42 +0000 http://www.tecmint.com/?p=3500#comment-2131297 I was bothered by one of these scripts (#3 gpg encryption), and strongly suggest at least checking the return code from gpg before removing any file, especially when teaching how to write scripts.

I don’t believe it is good practice to create scripts that remove files without pausing to ask permission first. The rm command has a -I option to prompt before deleting files which might be one possibility.

A better option might be to decrypt each encrypted file and compare it to the original before removal. I also suggest considering how unexpectedly the script as presented might operate when given file/directory names containing spaces.

I appreciate what you all do here, and understand the intention was to keep it simple. It’s great to teach scripting, but even better to teach defensive scripting. Feel free to take it or leave it, but that’s my two cents.

]]>
By: Jhornel https://www.tecmint.com/basic-shell-programming-part-ii/comment-page-1/#comment-1323450 Thu, 26 Mar 2020 02:29:40 +0000 http://www.tecmint.com/?p=3500#comment-1323450 This is my script. I am a beginner so I just used the old template. It was successful.

#!/bin/bash
echo "Welcome, now you want to decrypt a file/folder?"
echo "Currently I have a limitation. Place me to the same folder, where a file to be decrypted is present"
echo "Enter the Exact File Name with extension and the original filename before the encryption."
read file;
echo "Enter the exact file name before the encryption."
read file2;
gpg -d $file > $file2
echo "I have decrypted the file successfully..."
echo "Now removing the original encrypted file..."
rm -rf $file
]]>
By: Hritik Maurya https://www.tecmint.com/basic-shell-programming-part-ii/comment-page-1/#comment-1219086 Tue, 06 Aug 2019 11:09:05 +0000 http://www.tecmint.com/?p=3500#comment-1219086 Please give the decryption code i had tried writing but not working..

]]>
By: mujibur rahiman https://www.tecmint.com/basic-shell-programming-part-ii/comment-page-1/#comment-1104522 Mon, 25 Feb 2019 04:33:31 +0000 http://www.tecmint.com/?p=3500#comment-1104522 In reply to qazi abid.

gpg -d $file.gpg > decpt.txt try this it will work.

]]>