LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-19-2015, 09:29 PM   #1
dwhswebhosting
LQ Newbie
 
Registered: Jun 2004
Location: Earth
Distribution: Centos
Posts: 22

Rep: Reputation: 0
Any idea the command to find and replace a file by name and size


I want to do a /home search and remove for files named error_log that are over 5mb

I use this now but it doesn't factor space:

find /home -type f -name error_log -exec rm -f {} \;

Any idea how to add the 5 mb limit here?

Thanks!
 
Old 11-19-2015, 09:33 PM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,665
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Quote:
Originally Posted by dwhswebhosting View Post
Any idea how to add the 5 mb limit here?
Just one. https://duckduckgo.com/?q=find+file+by+size
 
Old 11-19-2015, 09:40 PM   #3
dwhswebhosting
LQ Newbie
 
Registered: Jun 2004
Location: Earth
Distribution: Centos
Posts: 22

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Habitual View Post
Can you paste the code here please.
 
Old 11-19-2015, 10:00 PM   #4
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,688

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by dwhswebhosting View Post
Can you paste the code here please.
You come across as fairly demanding. Here is another suggestion: RTFM. In this case, TFM can be accessed with man find. In the output of that command, you can search by typing the slash key on your keyboard, then entering something like "size" and pressing the ENTER key. Searching again is accomplished by pressing the lower-case n key, or upper case if you want to reverse the search direction. This is an important skill to learn and practice if you want to work with Linux and other UNIX-like operating systems.

Last edited by berndbausch; 11-19-2015 at 10:02 PM.
 
Old 11-19-2015, 10:43 PM   #5
dwhswebhosting
LQ Newbie
 
Registered: Jun 2004
Location: Earth
Distribution: Centos
Posts: 22

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by berndbausch View Post
You come across as fairly demanding. Here is another suggestion: RTFM. In this case, TFM can be accessed with man find. In the output of that command, you can search by typing the slash key on your keyboard, then entering something like "size" and pressing the ENTER key. Searching again is accomplished by pressing the lower-case n key, or upper case if you want to reverse the search direction. This is an important skill to learn and practice if you want to work with Linux and other UNIX-like operating systems.
No I didn't, you come off too sensitive.

But if I was searching for confusion you would be very helpful.

I was hoping for a command that could search and find a file bigger than a certain size and remove it directory wide. I suppose this could be too advanced, if so my bad for over estimating you. A modification

It's funny I teach children computer and sports skills all week for free at the boys club. Maybe next time I will just tell them to go find it on the Internet. After all sharing skills is like being a commy right.

My bad.
 
Old 11-20-2015, 01:08 AM   #6
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,688

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by dwhswebhosting View Post
No I didn't, you come off too sensitive.
No. I just wanted to point out that some people at LQ don't like this attitude. I don't care.
Quote:
Originally Posted by dwhswebhosting View Post
But if I was searching for confusion you would be very helpful.
You were confused to begin with. The philosophy here is that people should try before asking questions. Like trying to read the man page. If you don't understand the man page, you will get help.
Quote:
Originally Posted by dwhswebhosting View Post
I was hoping for a command that could search and find a file bigger than a certain size and remove it directory wide.
It's in the man page.
Quote:
Originally Posted by dwhswebhosting View Post
It's funny I teach children computer and sports skills all week for free at the boys club. Maybe next time I will just tell them to go find it on the Internet. After all sharing skills is like being a commy right.
I shared. So did Habitual.
Quote:
Originally Posted by dwhswebhosting View Post
My bad.
I agree.
 
Old 11-20-2015, 07:59 AM   #7
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,665
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Quote:
Originally Posted by dwhswebhosting View Post
Can you paste the code here please.
Gimme, gimme, gimme.
Even this guy cracked a book.

Good Luck.
 
Old 11-20-2015, 12:21 PM   #8
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,227

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Quote:
Originally Posted by Habitual View Post
I know we've been discussing the issues that lead to http://www.linuxquestions.org/questi...#faq_lqwelcome here at LQ recently, but in this case the OP gave an example of what they tried and asked a very specific question. Don't you think something along the line of "The flag you're looking for is -size, you may want to check out the man page for usage specifics." would have been significantly more helpful?

--jeremy
 
Old 11-20-2015, 12:24 PM   #9
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,227

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Quote:
Originally Posted by berndbausch View Post
You come across as fairly demanding. Here is another suggestion: RTFM.
Keep in mind that the RTFM attitude is something we try to avoid here at LQ.

Quote:
Originally Posted by berndbausch View Post
In this case, TFM can be accessed with man find. In the output of that command, you can search by typing the slash key on your keyboard, then entering something like "size" and pressing the ENTER key. Searching again is accomplished by pressing the lower-case n key, or upper case if you want to reverse the search direction. This is an important skill to learn and practice if you want to work with Linux and other UNIX-like operating systems.
This, however, is quite informative and helpful.

--jeremy
 
Old 11-20-2015, 12:27 PM   #10
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,227

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Quote:
Originally Posted by dwhswebhosting View Post
Can you paste the code here please.
On the flip side of my previous two posts... While we're happy to help you here at LQ, that help should come in an educational way which encourages you to learn and not to simply hand out exact specific commands for each task you'd like to accomplish.

--jeremy
 
Old 11-20-2015, 12:38 PM   #11
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,665
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Quote:
Originally Posted by jeremy View Post
Don't you think something along the line of "The flag you're looking for is -size, you may want to check out the man page for usage specifics." would have been significantly more helpful?

--jeremy
OMG. You'd think "Find file by size" in a search engine is telling him. but OK, I'll try to be 'nicer' next time.

Last edited by Habitual; 11-20-2015 at 12:40 PM.
 
Old 11-20-2015, 12:49 PM   #12
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,227

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Quote:
Originally Posted by Habitual View Post
OMG. You'd think "Find file by size" in a search engine is telling him. but OK, I'll try to be 'nicer' next time.
I think you're slightly missing the point. It's not about being "nice" (although LQ does aim to be friendly and welcoming to all members). If LQ is to simply be a bunch of links to search engines with specific phrases, what's the point? LQ itself should be a repository of knowledge available to the Open Source community as well as a place where that community can come together for discussion and collaboration.

--jeremy
 
Old 11-20-2015, 02:19 PM   #13
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,665
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Quote:
Originally Posted by jeremy View Post
I think you're slightly missing the point. It's not about being "nice" (although LQ does aim to be friendly and welcoming to all members). If LQ is to simply be a bunch of links to search engines with specific phrases, what's the point?
The 'point' is that Search Engines are how most of us found our answers, back when we didn't have anyone else to ask, we had to use them.
Maybe I'm skewed, but I get the impression that people just want to post a question, and wait for the answer in their inbox.

Search engines (dare I say it?) got most of us here!

I have to throw in the towel here.
As much as I love a good discussion, it's the same old hamster on the same old wheel.

But I'll try to adapt and be more voluntary with meaningful info.

Thanks Jeremy.
 
Old 11-20-2015, 02:25 PM   #14
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,227

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Quote:
Originally Posted by Habitual View Post
The 'point' is that Search Engines are how most of us found our answers, back when we didn't have anyone else to ask, we had to use them.
Search Engines and research are certainly how I got my answers, but that wasn't ideal either and is in large part why I created LQ.

Quote:
Originally Posted by Habitual View Post
Maybe I'm skewed, but I get the impression that people just want to post a question, and wait for the answer in their inbox.
I agree, we need to help create and foster a culture that encourages learning and does not expect spoon fed answers with no work by the OP. It's a difficult balance sometimes.

Quote:
Originally Posted by Habitual View Post
I have to throw in the towel here.
As much as I love a good discussion, it's the same old hamster on the same old wheel.

But I'll try to adapt and be more voluntary with meaningful info.

Thanks Jeremy.
I know it can be frustrating at time, but I really do appreciate it. It's valued members such as yourself that make LQ what it is. Thank you Habitual.

--jeremy
 
Old 11-20-2015, 05:14 PM   #15
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,688

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by jeremy View Post
Keep in mind that the RTFM attitude is something we try to avoid here at LQ
Admittedly the OP did trigger me with his/her remark, but I should try to be above such petty bickering.

Last edited by berndbausch; 11-20-2015 at 05:57 PM.
 
  


Reply

Tags
find command, remove


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
[SOLVED] how we can find and replace multiple file using sed command jayakumar01 Linux - Server 1 04-05-2012 08:53 AM
[SOLVED] Command to find in each file and replace one or two words Sha_unix Linux - Newbie 7 11-22-2011 02:44 PM
[SOLVED] command to find/replace in a text file? sneakyimp Linux - Newbie 17 02-15-2011 01:30 AM
Linux command to find and replace string within text file chips11 Linux - Newbie 5 11-24-2008 03:25 PM
command line edit -- global find/replace on text file w/o going into vi car182 Linux - Newbie 4 05-25-2006 06:42 PM


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