The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script for delete old files krishnarao Shell Programming and Scripting 4 01-13-2009 04:33 AM
How to delete files in UNIX using shell script theguy16 Shell Programming and Scripting 7 04-09-2008 04:40 AM
Automated script to delete the OLD Files laknar Shell Programming and Scripting 1 05-10-2007 02:34 AM
Need a script to delete multiple files navycow UNIX for Dummies Questions & Answers 3 01-16-2006 02:50 PM
how to delete empty files in a shell script rpnuge UNIX for Advanced & Expert Users 1 07-11-2002 04:56 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-01-2007
vats vats is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 10
script to delete files

hi guys,

i need a script to delete files that have core in their name ...it might be part of the file name or as a .core extension ...any file that has core as its extension....

i am only able to delete files which just have thier name as core

using this :

find $1 -type f -name "core" -exec rm -f {} \;

i am passing the directory to look for a a command line argument...

can anybody help me with this please....????
  #2 (permalink)  
Old 09-01-2007
kamitsin's Avatar
kamitsin kamitsin is offline
Registered User
  
 

Join Date: Nov 2006
Location: /dev/null
Posts: 177
Quote:
i am only able to delete files which just have thier name as core

using this :

find $1 -type f -name "core" -exec rm -f {} \;
You were almost there my friend

Code:
find $1 -type f -name "*core*" -exec rm -f {} \;
Cheers,
K
  #3 (permalink)  
Old 09-01-2007
vats vats is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 10
thx

thx man!! Hey by the way there is another thing with the core files which i describe below...


How would i do this!!!!

Last edited by vats; 09-01-2007 at 05:34 AM..
  #4 (permalink)  
Old 09-01-2007
kamitsin's Avatar
kamitsin kamitsin is offline
Registered User
  
 

Join Date: Nov 2006
Location: /dev/null
Posts: 177
check if the fileexists in that directory by using the conditional statement

Code:
if [[ -f filename ]]
then
     remove core
else
     warn user that the file does not exist # optional - depends on your requirement
fi
Hope this helps.

Cheers,
K
  #5 (permalink)  
Old 09-01-2007
vats vats is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 10
clarification..!!!

Hey buddy,
Thx a lot!!
I got the test part but i am unable to understand the full meaning of the problem....

which filename ur refering to in the test case...???Can u explain wht does the whole problem asks to do...?
  #6 (permalink)  
Old 09-01-2007
kamitsin's Avatar
kamitsin kamitsin is offline
Registered User
  
 

Join Date: Nov 2006
Location: /dev/null
Posts: 177
Quote:
I got the test part but i am unable to understand the full meaning of the problem....
is this a homework ???
  #7 (permalink)  
Old 09-01-2007
vats vats is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 10
no buddy!

no man its not homework!!!!i wanted to learn it ....as it will be useful for my work because i am mainly a windows person...my office has told me to learn linux.....its part of my learning thing!!!
Sponsored Links
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0