#!/bin/bash 
#run as ./local_to_particle_stack *local.star 
#you’ll need to add the header back after (with an additional field label for the image name 
rm all_gctf.star #remove output if it already exists 
touch all_gctf.star #make a fresh star file 
for i in "$@" #for each local.star 
do 
tail -n  +17 ${i} > local_tmp.star #grab everything but the header from local.star 
awk '{print $0, "\t", NR"@Extract/job019/aligned_frames/"$1"s"}' local_tmp.star > local_tmp2.star #print each line to a temp file, and add a field corresponding to the image name 
cat local_tmp2.star >> all_gctf.star #append the modified lines to the resulting star 
rm local_tmp.star #get rid of temp files. 
rm local_tmp2.star 
done 
