![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Delete all Files except the Latest Files | spkandy | Shell Programming and Scripting | 3 | 04-04-2009 04:31 AM |
| delete files using awk | igidttam | UNIX for Dummies Questions & Answers | 2 | 03-23-2007 10:18 PM |
| when I try to run rm on multiple files I have problem to delete files with space | umen | UNIX for Dummies Questions & Answers | 1 | 09-20-2005 03:20 AM |
| I can't delete some files | DISTURBED | UNIX for Dummies Questions & Answers | 4 | 08-01-2002 11:15 AM |
| which files to delete? | NOT A CLUE | UNIX for Dummies Questions & Answers | 1 | 09-19-2001 09:11 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
delete C files
A script that behaves both in interactive and nonineractive mode. When no arguments are supplied, it picks up each C program(Files with .c extension) from the current directory and lists the first 10 lines. It then prompts for deletion of the file. If the user supplies arguments with the script, it works on those files only.
|
|
||||
|
The code is not tested.
Code:
#! /usr/bin/bash
if [ "$1" = "" ] ; then
for i in `ls *.c`
do
echo "display first 10 lines of $i"
head -10 $i
printf " Do you want to delete the file $i [y]? "
read ANSWER
if [ x"$ANSWER" = x"y" ]; then
rm $i
fi
done
else
#work on $1
fi
Last edited by rdcwayx; 4 Days Ago at 04:44 AM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|