0

when I use the command to get the file size in bye using wc -c the command return two values, the size in byte and the file name, ex: the output for wc -c my_file is 322 my_file I need to get only the first value to use it if condition, and I need to use this specific command not any other one.. Any help please, thank you.

M. Edna
  • 5
  • 3

2 Answers2

4

Redirect stdin and wc wont know or echo the file name

wc -c < my_file
Milag
  • 1,793
  • 2
  • 9
  • 8
1

This can also be done without redirection or wastefully reading the whole file using stat:

stat -c %s my_file
agc
  • 7,973
  • 2
  • 29
  • 50