LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 07-02-2020, 11:06 PM   #1
Himeose
LQ Newbie
 
Registered: Jul 2020
Posts: 6

Rep: Reputation: Disabled
Bash script, im still new to linux


How to append an existing file?
The existing file in the wastebasket will have the version number zero appended to it and the newly deleted file will have version number 1 appended to it.
How the loop looks like?

My script be like

Quote:
#!/bin/sh
read file
mv $file mywastebasket
rm -i /home/himeose/mywastebasket/
So how am i gonna proceed?

actually this is the question given
Instructions


The goal of this assignment is to write a shell script to replace the rm command and
provide undelete capability similar to MS-DOS. Write a shell program to duplicate the
Linux rm command with the following features:

Your new rm command is delete

1. It will have a switch -i that will act in the same manner as in the rm command.

2. Instead of deleting the files, it will move them to a mywastebasket directory. If the file
already exists in the mywastebasket directory, then the existing file (in the
mywastebasket) will have the version number zero appended to it and the newly deleted
file will have version number one appended to it.
If the version number setup is already
in use for that file then the newest one will simply have the next version number in the
series appended to it. It's your choice as to what system to use for this. Just be sure that
it is a unique system and will not be part of any normal file naming convention you might
use.
-----------
For step 2

The loop for append
Mybe i should use
Quote:
If [ conditional expression1 ]
then
statement1
statement2
.
elif [ conditional expression2 ]
then
statement3
statement4
.
.
.
else
statement5
fi
how do i implement the append into the loop?
--------------
3. It will have a switch -c that will clear the entire mywastebasket after asking for
confirmation. The -i and -c switches may be combined to ask for confirmation on
individual files.
-----------------
for the step 3 i should using alias right for substitute -c,
-----------------

Don't forget that wildcards and multiple files are allowed on the command line. The
switches when combined may be in any order but must be before any filenames. Your
program must also catch any operator errors.

I'm still learning by myself and has poor understanding of linux things.

Last edited by Himeose; 07-03-2020 at 01:41 AM. Reason: addind the real instructions
 
Old 07-03-2020, 01:04 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,963

Rep: Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481
Bash script, im still new to linux

Please make your code more readable with code tags (see my signature).

Quote:
Originally Posted by Himeose View Post
How to append an existing file?
You want to append an existing file to what?
Quote:
rm -i /home/himeose/mywastebasket/
the above command will fail. To remove an empty directory, use rmdir. To remove a directory including all contents, rm -r.

In the remaining text, I don't know what is code, what is pseudocode, what is command output and what are your comments, In other words, I don't understand what you mean.

Can you provide an example?
 
Old 07-03-2020, 03:52 AM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,135

Rep: Reputation: Disabled
Just curious, where is the top post you're answering to?
 
Old 07-03-2020, 03:59 AM   #4
Himeose
LQ Newbie
 
Registered: Jul 2020
Posts: 6

Original Poster
Rep: Reputation: Disabled
Im post it, then edit, but after that it suddenly missing��
 
Old 07-03-2020, 04:24 AM   #5
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,927

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
Quote:
Originally Posted by Himeose View Post
Im post it, then edit, but after that it suddenly missing��
This is highly unusual. I started another thread in suggestions&feedback in order to investigate this issue.
 
Old 07-03-2020, 07:16 AM   #6
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,963

Rep: Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481
Quote:
Originally Posted by shruggy View Post
Just curious, where is the top post you're answering to?
A glitch?
 
Old 07-03-2020, 07:21 AM   #7
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,963

Rep: Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481
OP has created a new thread https://www.linuxquestions.org/quest...on-4175678054/.

Perhaps best to delete this one. I will report it.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I am new to Linux and bash script and love bash scripting. bubanaw Linux - Newbie 5 04-10-2019 10:28 AM
Finding Module Dependencies...(Still loading...still loading..still loading..HANG!!!) Aeudian Linux - General 3 08-11-2003 03:31 PM
Finding Module Dependencies.....(still loading....Still loading....still loading) Aeudian Linux - Newbie 1 07-28-2003 02:27 PM
suse 7.2 still wont install.. new info..still trying... AbbyXmix Linux - Software 3 10-07-2001 05:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration