LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-19-2005, 08:01 AM   #1
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Rep: Reputation: 15
Question Commands/Shell script ??


Hi!

I'd like to know what would be the commands to:

-find all files which have not been modified within 10 days

-list of processes without any associating terminal

I'd like also to write a shell script which would find the other hardlinks of a file. The name of the file is given as the first argument.

Thank you in advance for your help!
 
Old 04-19-2005, 08:26 AM   #2
laceupboots
Member
 
Registered: Dec 2003
Location: Houston
Distribution: Knoppix,lenova yoga 3, Samsung s6 -android
Posts: 307

Rep: Reputation: 30
Try going to koders.com and typing in your request you can look at others coding to find what you need.
 
Old 04-19-2005, 08:55 AM   #3
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 25, 26, RHL 5.2
Posts: 560

Rep: Reputation: 56
First one is...
Code:
find -mtime +10
 
Old 04-19-2005, 11:37 AM   #4
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
Thank you laceupboots and wmakowski for answering me!

find -mtime +10 finds files that were accessed or modified more than 10 days ago or am I get it wrong ? I 'd like to find files which have not been modified within 10 days. koders.com is great but I didn't find shell script codes for bash.
 
Old 04-19-2005, 12:42 PM   #5
gorzuate
LQ Newbie
 
Registered: Apr 2004
Location: IN
Distribution: Gentoo
Posts: 9

Rep: Reputation: 0
For processes:
Code:
ps a
 
Old 04-19-2005, 01:48 PM   #6
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
find all files which have not been modified within 10 days
find . -type f -mtime +11

Do this in the directory you want to search in. This will look for only files that are 11 or more days older (files that have not been modified within 10 days).

Quote:
list of processes without any associating terminal
ps -axuf | grep -v tty[1-6] | grep -v pts

Quote:
I'd like also to write a shell script which would find the other hardlinks of a file
Interesting request...now why you would want to do this? There are 2 types of links in linux: hard links and symbolic (soft) links. If you don't see a softlink in your directory, then the rest are hard links.

find . -type l

This will show you soft links in the directory that you run this under. You can modify this so that it will disregard the list of files that this 'find' command sees. I'll give that simple project to you. Let us know if you need help (after you play around with some scripting of course) .

-twantrd
 
Old 04-19-2005, 04:13 PM   #7
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
Thanks a lot twantrd for helping! My shell script to find the other hardlinks is in progress but I still miss something or may be everything to put the things all together in a bash script:

First I have to find the file entered as an argument : find ~ -name $1
Then I need to print the inode: ls -i $1 | awk '{print $1}'
Finally I need to print all the other files (hardlinks) with the same inode : find ~ -inum $1 -print
 
Old 04-19-2005, 07:05 PM   #8
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
That looks fine to me. What's the problem you are encountering?

-twantrd
 
Old 04-20-2005, 03:52 AM   #9
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
Is it possible to store in a variable the inode number I got from:
Code:
 ls -i $1 | awk '{print $1}'
so that I can assign it to:
Code:
find ~ -inum $1 -print
 
Old 04-20-2005, 04:54 AM   #10
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
I'd try something like
Code:
INUM=`ls -i $1 | awk '{print $1}'`
find ~ -inum $INUM -print
Groetjes,

Kees-Jan
 
Old 04-20-2005, 11:24 AM   #11
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Yup, kees-jan code is correct. You can also do this:

Code:
INUM=$(ls -i $1 | awk '{print $1}')
find ~ -inum $INUM -print
Which does the exact same job. I just offered that solution as back-ticks are now deprecated and that's pretty much the standard way now of assigning variables.

-twantrd
 
Old 04-21-2005, 10:58 AM   #12
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
I just tried your solutions and it works very fine ! Thanks again twantrd and kees-jan for your help.

Cheers !

paraiso
 
  


Reply



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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Commands from shell script not working Grassie Coetzee Linux - Software 2 03-13-2005 02:31 PM
Use a shell script to do login and other commands jpan Linux - General 15 01-12-2005 06:52 AM
shell commands! krishlinux General 1 10-05-2003 04:47 AM

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

All times are GMT -5. The time now is 01:04 PM.

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