File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 77
88parser .add_argument ("-w" , action = "store_true" , help = "Print word count" )
99
10+ parser .add_argument ("-c" , action = "store_true" , help = "Print byte count" )
11+
1012parser .add_argument ("files" , nargs = "+" , help = "Files to process" )
1113
1214args = parser .parse_args ()
2628 content = f .read ()
2729 lines = content .count ("\n " )
2830 words = len (content .split ())
29- tbytes = len ( content . encode ( "utf-8" ) )
31+ tbytes = os . path . getsize ( file )
3032
33+
3134
3235 total_lines += lines
3336 total_words += words
3740 print (f"{ lines :} { file } " )
3841
3942 elif args .w :
40- print (f"{ words :} { file } " )
43+ print (f"{ words :} { file } " )
44+
45+ elif args .c :
46+ print (f"{ tbytes :} { file } " )
4147
4248 else :
43- print (f"{ lines :>3} { words :>3} { tbytes :>3} { file } " ) # to print data from per life
49+ print (f"{ lines :>3} { words :>3} { tbytes :>3} { file } " ) # to print data from per file
4450
4551#to print total output
4652if multiple_files :
You can’t perform that action at this time.
0 commit comments