How do I compare an argument's size to an arbitrary number of megabytes?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
So, I want to compare a piece of codes number of megabytes.
What I think the answer is:
#!/bin/bash
FILE=$1
export FILE1
if [ -f$1 ];
then
echo "Hello world!"
fi
if [ $# -lt 1 ]; then
echo "This file is less than 1 megabyte"
fi
Of course, I don't think this is the fullest answer, as I'm just comparing a file argument to the number 1, so how would I know if this is greater than the number 1 in bytes or megabytes? Does Bash already account for this? Or is there a command I can use to translate to megabytes?
bash
add a comment |Â
up vote
0
down vote
favorite
So, I want to compare a piece of codes number of megabytes.
What I think the answer is:
#!/bin/bash
FILE=$1
export FILE1
if [ -f$1 ];
then
echo "Hello world!"
fi
if [ $# -lt 1 ]; then
echo "This file is less than 1 megabyte"
fi
Of course, I don't think this is the fullest answer, as I'm just comparing a file argument to the number 1, so how would I know if this is greater than the number 1 in bytes or megabytes? Does Bash already account for this? Or is there a command I can use to translate to megabytes?
bash
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So, I want to compare a piece of codes number of megabytes.
What I think the answer is:
#!/bin/bash
FILE=$1
export FILE1
if [ -f$1 ];
then
echo "Hello world!"
fi
if [ $# -lt 1 ]; then
echo "This file is less than 1 megabyte"
fi
Of course, I don't think this is the fullest answer, as I'm just comparing a file argument to the number 1, so how would I know if this is greater than the number 1 in bytes or megabytes? Does Bash already account for this? Or is there a command I can use to translate to megabytes?
bash
So, I want to compare a piece of codes number of megabytes.
What I think the answer is:
#!/bin/bash
FILE=$1
export FILE1
if [ -f$1 ];
then
echo "Hello world!"
fi
if [ $# -lt 1 ]; then
echo "This file is less than 1 megabyte"
fi
Of course, I don't think this is the fullest answer, as I'm just comparing a file argument to the number 1, so how would I know if this is greater than the number 1 in bytes or megabytes? Does Bash already account for this? Or is there a command I can use to translate to megabytes?
bash
bash
asked 5 mins ago
The_Senate
31
31
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476939%2fhow-do-i-compare-an-arguments-size-to-an-arbitrary-number-of-megabytes%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password