Reputation: 23
I have studied shell recently and I saw a sample code in the book and here it is:
File.sh
#!bin/bash
file_count=0;
for file in *
do
let file+=1
done
echo "There are $file_count files in folder"
I tried this code and result is so weird.
I has three files in folder, File.sh
, Test.sh
, Child.sh
but file_count
value is 6 in result.
I print value of file and the result is:
child.sh
child.sh~
File.sh
Test~
Test.sh
Test.sh~
Wonder why this happened.
Upvotes: 1
Views: 28
Reputation: 174816
The file names ended with ~
are backup files created by some famous text editors (like gedit
). Once you open a file through such text editors, it would automatically creates a backup for each file you opened.
Upvotes: 1