Skip to content

Commit 830d197

Browse files
committed
Delete repetition lines
1 parent 66e8b67 commit 830d197

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
node_modules
2+
.DS_Store
3+
__pycache__/
4+
*.pyc

implement-shell-tools/cat/myCat.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { program } from "commander";
22
import { promises as fs } from "node:fs";
3-
import process from "node:process";
43

54
program
65
.name("myCat")
@@ -17,16 +16,15 @@ let lineNumber = 1;
1716

1817
for (const filename of files) {
1918
const content = await fs.readFile(filename, "utf-8");
19+
const lines = content.split("\n");
2020

2121
if (opts.n) {
22-
const lines = content.split("\n");
2322

2423
for (const line of lines) {
2524
console.log(lineNumber + " " + line);
2625
lineNumber++;
2726
}
2827
} else if (opts.b) {
29-
const lines = content.split("\n");
3028

3129
for (const line of lines) {
3230
if (line.trim() !== "") {

0 commit comments

Comments
 (0)