I'm new in bash scripting and I'm trying to create a bash script which can create multiple file with content (around 10000 lines [no matters what text]) but with user input. I made a script which create files (see below) but how can I fill each file with 10000 lines? Thank you in advance!
#!/bin/bash
echo How many files do you want to create?
read numberOfFiles
echo
echo Please enter the files name with should start:
read nameForFiles
echo
for i in $(seq 1 $numberOfFiles)
do
touch $nameForFiles-$i.txt
done
CodePudding user response:
Replace your touch
command with this:
for ((j=0; j<9999; j )); do echo "Cyrus was here"; done > "$nameForFiles-$i.txt"
CodePudding user response:
#!/usr/bin/env bash
read -rp "How many files do you want to create? " numberOfFiles
echo
read -rp "Please enter the file name: " nameForFiles
echo
for ((n=1;n<=numberOfFiles;n )); do
for i in {1..1000}; do
echo "line $i" >> "${nameForFiles}"-"${n}".txt
done
done