-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93cc272
commit 6401709
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Check if the input file and number of repetitions are provided | ||
if [ "$#" -ne 3 ]; then | ||
printf "\033[0;31mUsage: $0 <filename> <number_of_repetitions>\033[0m\n" | ||
exit 1 | ||
fi | ||
|
||
input_file=$1 | ||
repetitions=$2 | ||
output_file=$3 | ||
|
||
# Check if the input file exists | ||
if [ ! -f "$input_file" ]; then | ||
printf "\033[0;31mError: File '$input_file' not found.\033[0m\n" | ||
exit 1 | ||
fi | ||
|
||
# Clear the output file if it already exists | ||
> "$output_file" | ||
|
||
# Concatenate the file with itself specified number of times | ||
for (( i=0; i<repetitions; i++ )) | ||
do | ||
cat "$input_file" >> "$output_file" | ||
done | ||
|
||
printf "\033[0;32mSuccessfully created '$output_file'.\033[0m\n" |