-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19_delete_disply_swp.sh
More file actions
41 lines (36 loc) · 965 Bytes
/
Copy path19_delete_disply_swp.sh
File metadata and controls
41 lines (36 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<<Documentation
NAME : V.Karthikeyan
DATE : 23.05.2021
DESCRIPTION : Write a script to delete all the .swp files found in your system or directory.
INPUT : ./19_delete_disply_swp.sh ECEP
OUTPUT : ECEP/LS/2.swp
ECEP/LS/1.swp
Documentation
#!/bin/bash
if [ $# -eq 0 ] #if no argument is passed it checks from home directory
then
no_of_swp=`find ~ -name "*.swp" |wc -l` #no of swp files present
if [ $no_of_swp -eq 0 ]
then
echo "No swp file are present"
else
find ~ -name "*.swp" #print the directory of files
find ~ -name "*.swp" -delete #delete files
fi
elif [ $# == 1 ]
then
cd
if [ -d $1 ]
then
no_of_swp=`find $1 -name "*swp" |wc -l` #in the files in $1 directory
if [ $no_of_swp -eq 0 ]
then
echo "No swp file are present"
else
find $1 -name "*swp"
find $1 -name "*swp" -delete
fi
else
echo "Directory not present"
fi
fi