Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/File-size/UNIX-Shell/file-size-1.sh
Normal file
2
Task/File-size/UNIX-Shell/file-size-1.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
size1=$(ls -l input.txt | tr -s ' ' | cut -d ' ' -f 5)
|
||||
size2=$(ls -l /input.txt | tr -s ' ' | cut -d ' ' -f 5)
|
||||
10
Task/File-size/UNIX-Shell/file-size-2.sh
Normal file
10
Task/File-size/UNIX-Shell/file-size-2.sh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
echo "# ls:"
|
||||
ls -la input.txt
|
||||
|
||||
echo "# stat:"
|
||||
stat input.txt
|
||||
|
||||
echo "# Size:"
|
||||
size1=$(ls -l input.txt | tr -s ' ' | cut -d ' ' -f 5)
|
||||
size2=$(wc -c < input.txt | tr -d ' ')
|
||||
echo $size1, $size2
|
||||
2
Task/File-size/UNIX-Shell/file-size-3.sh
Normal file
2
Task/File-size/UNIX-Shell/file-size-3.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
size1=$(wc -c < input.txt | tr -d ' ')
|
||||
size2=$(wc -c < /input.txt | tr -d ' ')
|
||||
2
Task/File-size/UNIX-Shell/file-size-4.sh
Normal file
2
Task/File-size/UNIX-Shell/file-size-4.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
size1=$(stat -f %z input.txt)
|
||||
size2=$(stat -f %z /input.txt)
|
||||
5
Task/File-size/UNIX-Shell/file-size-5.sh
Normal file
5
Task/File-size/UNIX-Shell/file-size-5.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# from module 'zsh/stat', load builtin 'zstat'
|
||||
zmodload -F zsh/stat b:zstat
|
||||
|
||||
size1=$(zstat +size input.txt)
|
||||
size2=$(zstat +size /input.txt)
|
||||
17
Task/File-size/UNIX-Shell/file-size-6.sh
Normal file
17
Task/File-size/UNIX-Shell/file-size-6.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
unset PATH # No cheating!
|
||||
|
||||
countbytes(){
|
||||
size=0
|
||||
|
||||
# Read the lines in the file
|
||||
while read -r;do
|
||||
size=$((size+${#REPLY}+1)) # +1 to account for the newline
|
||||
done < "$1"
|
||||
size=$((size+${#REPLY})) # Account for partial lines
|
||||
|
||||
echo "$size $1"
|
||||
}
|
||||
|
||||
countbytes input.txt
|
||||
countbytes /input.txt
|
||||
Loading…
Add table
Add a link
Reference in a new issue