Skip to main content
edited title
Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

split file into 30N pieces with same name but different target directories

Tweeted twitter.com/StackUnix/status/925022228172935170
deleted 51 characters in body; edited title
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

split file into 30 pieces with same name but different parenttarget directories

I want to split sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal files. I have foldersdirectories called prog1 to prog30 and I would like to save split the file into these foldersdirectories with athe same filename. For example /prog1/myfile.txt, /prog2/myfile.txt to /prog30/myfile.txt. I searched but I couldn't find any similar questions.
The script runs in prog folder and

Here is my bash script called divide.sh
My bash script is below runs in prog directory

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/

totalline=$(wc -l < ./sourcefile.txt)

divide="$(( $totalline / 30 ))"

split --lines=$divide $./prog1/myfile.txt

 exit 1
fi
#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/
totalline=$(wc -l < ./sourcefile.txt)   
divide="$(( $totalline / 30 ))"   
split --lines=$divide $./prog1/myfile.txt    
exit 1
fi

split file into 30 pieces with same name but different parent directories

I want to split sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal files. I have folders called prog1 to prog30 I would like to save split the file into these folders with a same filename. For example /prog1/myfile.txt, /prog2/myfile.txt to /prog30/myfile.txt. I searched but I couldn't find any similar questions.
The script runs in prog folder and is called divide.sh
My bash script is below

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/

totalline=$(wc -l < ./sourcefile.txt)

divide="$(( $totalline / 30 ))"

split --lines=$divide $./prog1/myfile.txt

 exit 1
fi

split file into 30 pieces with same name but different target directories

I want to split sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal files. I have directories called prog1 to prog30 and I would like to save split the file into these directories with the same filename. For example /prog1/myfile.txt, /prog2/myfile.txt to /prog30/myfile.txt.

Here is my bash script called divide.sh runs in prog directory

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/
totalline=$(wc -l < ./sourcefile.txt)   
divide="$(( $totalline / 30 ))"   
split --lines=$divide $./prog1/myfile.txt    
exit 1
fi
retag; edited title to be more inline with the question
Source Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262

split file which contains 10000 lines into 30 pieces with same name but different fileparent directories

I want to split sourcefile.txt sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal filefiles. I have folders called /prog1/prog1 to /prog30/prog30 I would like to save split filesthe file into these folders with a same filename. For example /prog1/myfile.txt /prog2/myfile.txt/prog1/myfile.txt, /prog2/myfile.txt to /prog30/myfile/prog30/myfile.txt.txt I searchsearched but itI couldn't find near my question. Thank youany similar questions.

 
The script runs in /prog/prog folder and is called divide.sh

Mydivide.sh
My bash script is below

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/

totalline=$(wc -l < ./sourcefile.txt)

divide="$(( $totalline / 30 ))"

split --lines=$divide $./prog1/myfile.txt

 exit 1
fi

split file which contains 10000 lines into 30 different file

I want to split sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal file. I have folders called /prog1/ to /prog30/ I would like to save split files into these folders with a same filename. For example /prog1/myfile.txt /prog2/myfile.txt to /prog30/myfile.txt I search but it couldn't find near my question. Thank you.

  script runs in /prog/ folder called divide.sh

My bash script is below

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/

totalline=$(wc -l < ./sourcefile.txt)

divide="$(( $totalline / 30 ))"

split --lines=$divide $./prog1/myfile.txt

 exit 1
fi

split file into 30 pieces with same name but different parent directories

I want to split sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal files. I have folders called prog1 to prog30 I would like to save split the file into these folders with a same filename. For example /prog1/myfile.txt, /prog2/myfile.txt to /prog30/myfile.txt. I searched but I couldn't find any similar questions.
The script runs in prog folder and is called divide.sh
My bash script is below

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/

totalline=$(wc -l < ./sourcefile.txt)

divide="$(( $totalline / 30 ))"

split --lines=$divide $./prog1/myfile.txt

 exit 1
fi
Source Link
danone
  • 304
  • 1
  • 3
  • 14
Loading