strutture:roma1:experiments:ams2:internal_note_naia:bash_script
Differences
This shows you the differences between two versions of the page.
strutture:roma1:experiments:ams2:internal_note_naia:bash_script [2025/05/02 13:54] – created bartolon@infn.it | strutture:roma1:experiments:ams2:internal_note_naia:bash_script [2025/05/02 13:56] (current) – bartolon@infn.it | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | # | ||
+ | # Directory path where .root files are located | ||
+ | DIR="/ | ||
+ | # Output file path (explicitly in current directory) | ||
+ | OUTPUT=" | ||
+ | # Minimum and maximum Unix timestamps for filtering | ||
+ | MIN_TIME=1640994629 | ||
+ | MAX_TIME=1646093960 | ||
+ | # Debug: Show current directory and permissions | ||
+ | echo " | ||
+ | echo " | ||
+ | # Remove the output file if it already exists | ||
+ | echo " | ||
+ | rm -f " | ||
+ | # Test write permission | ||
+ | echo " | ||
+ | touch " | ||
+ | rm -f " | ||
+ | # Change to the input directory | ||
+ | echo " | ||
+ | cd " | ||
+ | # Use ls and awk to filter and sort files in one go | ||
+ | echo " | ||
+ | ls -1 *.root | awk -v dir=" | ||
+ | { | ||
+ | # Extract timestamp by removing .root extension | ||
+ | timestamp = substr($0, 1, length($0)-5) | ||
+ | # Check if timestamp is numeric and within range | ||
+ | if (timestamp ~ /^[0-9]+$/ && timestamp > min && timestamp < max) { | ||
+ | print dir "/" | ||
+ | } | ||
+ | }' | sort -n > " | ||
+ | # Count the number of lines in the output file | ||
+ | count=$(wc -l < " | ||
+ | # Print completion message | ||
+ | echo "File $OUTPUT created successfully with $count entries." |