Skip to content

Commit

Permalink
Create 16.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
gliargovas authored Sep 8, 2023
1 parent 0e9d1c8 commit 8fb9b63
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions evaluation/benchmarks/dgsh/sequential/16.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Initialize the necessary temporary files
file1=$(mktemp)
file2=$(mktemp)
file3=$(mktemp)
file4=$(mktemp)

# Save the ls output to a temporary file
ls -n > "$file1"

# Reorder fields in DIR-like way
awk '!/^total/ {print $6, $7, $8, $1, sprintf("%8d", $5), $9}' "$file1" > "$file2"

# Count number of files
wc -l "$file1" | tr -d \\n > "$file3"
echo -n ' File(s) ' >> "$file3"
awk '{s += $5} END {printf("%d bytes\n", s)}' "$file1" >> "$file3"

# Count number of directories and print label for number of dirs and calculate free bytes
grep -c '^d' "$file1" | tr -d \\n > "$file4"
df -h . | awk '!/Use%/{print " Dir(s) " $4 " bytes free"}' >> "$file4"

# Display the results
cat "$file2" "$file3" "$file4"

0 comments on commit 8fb9b63

Please sign in to comment.