Print Line Numbers and File contents
September10
Create a file called printNum.txt
1 2 3 4 5 6 | $ echo "A > B > C > D > E > F" > printNum.txt |
Display the file using the cat command
1 2 3 4 5 6 7 | $ cat printNum.txt
A
B
C
D
E
F |
Put numbers in all the lines using cat command
1 2 3 4 5 6 7 | $ cat -n printNum.txt 1 A 2 B 3 C 4 D 5 E 6 F |
Put number in all the lines using awk command
1 2 3 4 5 6 7 | $ awk '{print NR,$0}' printNum.txt 1 A 2 B 3 C 4 D 5 E 6 F |
Using Perl
1 2 3 4 5 6 7 | $ perl -lane 'print "$. $_" ;' printNum.txt 1 A 2 B 3 C 4 D 5 E 6 F |
Using grep command
1 2 3 4 5 6 7 | $ cat my_test NUM_SCENARIOS=100 REP_NUM_SCENARIOS=10 $ grep -n . my_test 1:NUM_SCENARIOS=100 2:REP_NUM_SCENARIOS=10 |
Recent Comments