LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2020, 09:19 AM   #1
BringMara
LQ Newbie
 
Registered: May 2020
Posts: 5

Rep: Reputation: Disabled
Exclamation Shell script project Asap


Hi,I need to make a shell script that copies to a separate Path only the files in which the user modified more than 20 lines at a certain time/date.Files are archived and then deleted.
 
Old 05-14-2020, 09:21 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,651

Rep: Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763Reputation: 4763
ok, and what is your problem? Where did you stuck?
 
1 members found this post helpful.
Old 05-14-2020, 09:21 AM   #3
shruggy
Member
 
Registered: Mar 2020
Posts: 948

Rep: Reputation: Disabled
Not enough info. Are the files kept in a VCS?

Last edited by shruggy; 05-14-2020 at 03:17 PM.
 
1 members found this post helpful.
Old 05-14-2020, 09:26 AM   #4
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,790

Rep: Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427
While the filesystem keeps the time of last modification, it's only possible to know the modified lines if the original file is kept. Also, if the file is modified today and again tomorrow, today's modification date is forgotten.

In other words, your requirement can't be fulfilled without a very special filesystem type, and/or a special application with which the files are altered.
 
1 members found this post helpful.
Old 05-14-2020, 09:28 AM   #5
GPGAgent
Member
 
Registered: Oct 2018
Location: Cornwall UK
Distribution: Mint
Posts: 370

Rep: Reputation: 40
Quote:
Originally Posted by BringMara View Post
Hi,I need to make a shell script that copies to a separate Path only the files in which the user modified more than 20 lines at a certain time/date.Files are archived and then deleted.
1. What sort of files, text, word, spreadsheet?

2. So if 19 lines were modified it two days ago and 1 line today it would be rejected? Because 20 lines weren't modified today?

3. You copy files to a specified path and then you archive them and then you delete them. Seems a bit odd.

Puzzled???
 
1 members found this post helpful.
Old 05-14-2020, 09:38 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,816

Rep: Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317
Quote:
Originally Posted by BringMara View Post
Hi,I need to make a shell script that copies to a separate Path only the files in which the user modified more than 20 lines at a certain time/date.Files are archived and then deleted.
Then by all means, you should write one to do just that. Given that your subject line is "Shell script project Asap", that says to me this is a homework question. Since you need it 'ASAP', you should start writing immediately.

And if you get STUCK, you need to post what YOU have written/done/tried, give us examples of what you're using for input, what you want as output, and where things are failing, and we will be glad to assist you from there. But we are not the place for 'need my homework done ASAP'
 
2 members found this post helpful.
Old 05-25-2020, 06:29 AM   #7
BringMara
LQ Newbie
 
Registered: May 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
I am really struggling with a homework.I have to make a shell script that will copy to a separate path the files in which the user modified more than 20 lines on a specific date.The files should also be archived and them deleted.
What I know right now:
To copy a file somewhere else i use this:
$ ls dir1/
dir2/
$ cp -r dir1/ dir1.copy
$ ls dir1.copy
dir2/
To show number of lines in a file and modified files in the last days:
wc -l file1
mtime or find ~/Desktop -type f -newermt 2020-05-22 -ls for example

I use tar for archives and rm to remove.The problem is I have very little experience with linux and I don’t know how to form the final shell script.
 
Old 05-25-2020, 08:35 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,705
Blog Entries: 13

Rep: Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922
Quote:
Originally Posted by BringMara View Post
I am really struggling with a homework.I have to make a shell script that will copy to a separate path the files in which the user modified more than 20 lines on a specific date.The files should also be archived and them deleted.
What I know right now:
To copy a file somewhere else i use this:
$ ls dir1/
dir2/
$ cp -r dir1/ dir1.copy
$ ls dir1.copy
dir2/
To show number of lines in a file and modified files in the last days:
wc -l file1
mtime or find ~/Desktop -type f -newermt 2020-05-22 -ls for example

I use tar for archives and rm to remove.The problem is I have very little experience with linux and I donít know how to form the final shell script.
Please review the link from my signature titled My Bash Blog.

It provides some good overview of bash programming, how to start and how to debug.
 
1 members found this post helpful.
Old 05-26-2020, 03:18 AM   #9
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,758

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
Check out this link: https://bash.cyberciti.biz/guide/Hello,_World!_Tutorial

Or open Google.com and search for this keyword: "how to create a shell script in linux"

Or this keyword: "linux bash hello world tutorial"

Example:
Quote:
#!/bin/bash
echo "Hello, World!"
echo "Knowledge is power. But don't do a shortcut to the knowledge. Learn the hard way."
echo "Hello, World!" <-- is a command, so technically you can replace it with any commands in Linux

Good luck!!!
 
1 members found this post helpful.
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash shell script problems need help ASAP! chumpp Linux - Newbie 4 03-16-2012 04:04 PM
Details on using Mysql with ruby, project struck ,needed help asap! wrapster Programming 2 07-27-2009 08:44 PM
Newbie Needs Help ASAP bigbill2003 Linux - Software 17 03-12-2003 04:28 PM
really weird DNS issue. Help needed ASAP! Supp0rtLinux Linux - Networking 2 05-20-2002 10:02 PM
Problems with sendmail. Please help ASAP yank_ Linux - Networking 1 04-25-2001 02:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration