File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
implement-shell-tools/cat Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ def main():
1414
1515 args = parser .parse_args ()
1616
17- line_number = 1
18- non_blank_line_number = 1
17+ counter = 1
1918
2019 for file_path in args .path :
2120 try :
@@ -27,14 +26,14 @@ def main():
2726 if i == len (lines ) - 1 and line == "" : # Skip the last empty line if it exists
2827 break
2928 prefix = ""
30- if args .n :
31- prefix = str (line_number ).rjust (6 ) + " "
32- elif args .b and line != "" :
33- prefix = str (non_blank_line_number ).rjust (6 ) + " "
29+ if args .b :
30+ if line != "" :
31+ prefix = str (counter ).rjust (6 ) + " "
32+ counter += 1
33+ elif args .n :
34+ prefix = str (counter ).rjust (6 ) + " "
35+ counter += 1
3436 print (prefix + line )
35- line_number += 1
36- if line != "" :
37- non_blank_line_number += 1
3837
3938 except FileNotFoundError :
4039 print (f"cat: { file_path } : No such file or directory" )
You can’t perform that action at this time.
0 commit comments