I know I can use
ls -lat to find out how many bytes has a file and then multiply by 8 to find out how many bits. But is this possible in only one command line?
A shell + GNU coreutils solution:
echo $(( 8 * $(stat -c%s FILE) ))
-c%s option to
stat returns just the file size in bytes, eliminating any need for additional text processing. This syntax is supported by GNU coreutils and therefore should work under most linux distributions.
As an exception on linux, if one is running zsh with the optional zsh/stat module, then one needs to specify a path to get the GNU coreutils:
echo $(( 8 * $(command stat -c%s FILE) ))