Skip to main content
added 311 characters in body
Source Link
KB73
  • 1
  • 3

Try this:

arr=($(cut -d ' ' -f1,2 < $*)) mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done) 

The first line will create an array with only the first 2 fields from the input. Each element in the array will have two fields (first, last). The second line will go through each element in the array and substitute each field according the requirement and make a new directory out of each new formed entry.

Try this:

arr=($(cut -d ' ' -f1,2 < $*)) mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done) 

Try this:

arr=($(cut -d ' ' -f1,2 < $*)) mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done) 

The first line will create an array with only the first 2 fields from the input. Each element in the array will have two fields (first, last). The second line will go through each element in the array and substitute each field according the requirement and make a new directory out of each new formed entry.

added 13 characters in body
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 266

Try this: arr=($(cut -d ' ' -f1,2 < $*));mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done)

arr=($(cut -d ' ' -f1,2 < $*)) mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done) 

Try this: arr=($(cut -d ' ' -f1,2 < $*));mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done)

Try this:

arr=($(cut -d ' ' -f1,2 < $*)) mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done) 
Post Undeleted by KB73
Post Deleted by KB73
Source Link
KB73
  • 1
  • 3

Try this: arr=($(cut -d ' ' -f1,2 < $*));mkdir $(for ((i=0;i<${#arr[@]};i=i+2)); do echo ${arr[$i+1]:0:4}${arr[$i]:0:2}; done)