forked from jarv/cmdchallenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenges.yaml
702 lines (692 loc) · 27.8 KB
/
challenges.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
---
# slug: name of the challenge (required)
# description: describe teh challenge (required)
# example: solution for the challenge (required)
# expected_output:
# lines: lines returned from the command, as an array.
# Values *must* be strings, not integers! (required)
# order: whether or not order matters (optional, default is true)
# re_sub: regex substitution on the output lines (optional)
# regex: lines are regular expressions (optional)
# version: if the challenge is modified this number should be bumped
# refresh the cache.
# author: Add a field for contributions.
- slug: hello_world
version: 4
author: cmdchallenge
description: |
Print "hello world".
Hint: There are many ways to print text on
the command line, one way is with the 'echo'
command.
Try it below and good luck!
example: echo 'hello world'
expected_output:
lines:
- 'hello world'
- slug: current_working_directory
version: 4
author: cmdchallenge
description: |
Print the current working directory.
example: pwd
expected_output:
lines:
- '/var/challenges/current_working_directory'
- slug: list_files
version: 5
author: cmdchallenge
description: |
List names of all the files in the current
directory, one file per line.
example: ls
example_fail: echo README
expected_output:
lines:
- 'README'
- slug: print_file_contents
version: 4
author: cmdchallenge
description: |
There is a file named "access.log" in the
current directory. Print the contents.
example: cat access.log
expected_output:
lines:
- 163.56.115.58 - - [09/Jan/2017:22:29:57 +0100] "GET /posts/2/display HTTP/1.0" 200 3240
- 75.113.188.234 - - [09/Jan/2017:22:30:43 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 1116
- 69.16.40.148 - - [09/Jan/2017:22:34:33 +0100] "GET /pages/create HTTP/1.0" 500 3471
- 225.219.54.140 - - [09/Jan/2017:22:35:30 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 500 2477
- 207.243.19.2 - - [09/Jan/2017:22:38:03 +0100] "GET /bar/create HTTP/1.0" 200 1116
- 199.37.62.156 - - [09/Jan/2017:22:42:18 +0100] "GET /posts/1/display HTTP/1.0" 200 2477
- 55.74.240.123 - - [09/Jan/2017:22:44:25 +0100] "POST /posts/1/display HTTP/1.0" 200 3471
- 251.111.109.143 - - [09/Jan/2017:22:49:02 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 2477
- 101.163.230.250 - - [09/Jan/2017:22:52:31 +0100] "DELETE /posts/2/display HTTP/1.0" 404 2477
- 200.19.168.148 - - [09/Jan/2017:22:57:11 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 3471
- slug: last_lines
version: 4
author: cmdchallenge
disp_title: Last lines in a file.
description: |
Print the last 5 lines of "access.log".
example: tail -n 5 access.log
expected_output:
lines:
- 199.37.62.156 - - [09/Jan/2017:22:42:18 +0100] "GET /posts/1/display HTTP/1.0" 200 2477
- 55.74.240.123 - - [09/Jan/2017:22:44:25 +0100] "POST /posts/1/display HTTP/1.0" 200 3471
- 251.111.109.143 - - [09/Jan/2017:22:49:02 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 2477
- 101.163.230.250 - - [09/Jan/2017:22:52:31 +0100] "DELETE /posts/2/display HTTP/1.0" 404 2477
- 200.19.168.148 - - [09/Jan/2017:22:57:11 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 3471
- slug: find_string_in_a_file
version: 4
author: cmdchallenge
description: |
There is a file named "access.log" in the
current working directory. Print all lines
in this file that contains the string "GET".
example: grep 'GET' access.log
expected_output:
lines:
- 163.56.115.58 - - [09/Jan/2017:22:29:57 +0100] "GET /posts/2/display HTTP/1.0" 200 3240
- 75.113.188.234 - - [09/Jan/2017:22:30:43 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 1116
- 69.16.40.148 - - [09/Jan/2017:22:34:33 +0100] "GET /pages/create HTTP/1.0" 500 3471
- 225.219.54.140 - - [09/Jan/2017:22:35:30 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 500 2477
- 207.243.19.2 - - [09/Jan/2017:22:38:03 +0100] "GET /bar/create HTTP/1.0" 200 1116
- 199.37.62.156 - - [09/Jan/2017:22:42:18 +0100] "GET /posts/1/display HTTP/1.0" 200 2477
- 251.111.109.143 - - [09/Jan/2017:22:49:02 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 2477
- 200.19.168.148 - - [09/Jan/2017:22:57:11 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 3471
- slug: search_for_files_containing_string
version: 4
author: cmdchallenge
description: |
Print all files in the current directory,
one per line (not the path, just the filename)
that contain the string "500".
example: grep -l 500 *
expected_output:
order: false
lines:
- README
- access.log
- access.log.1
- slug: search_for_files_by_extension
version: 4
author: cmdchallenge
description: |
Print the relative file paths, one path
per line for all filenames that start with
"access.log" in the current directory.
example: find . -name 'access.log*'
expected_output:
order: false
re_sub: ['^\./', '']
lines:
- 'access.log'
- 'access.log.1'
- 'access.log.2'
- slug: search_for_string_in_files_recursive
version: 4
author: cmdchallenge
description: |
Print all matching lines (without the filename
or the file path) in all files under the current
directory that start with "access.log" that
contain the string "500". Note that there are no
files named "access.log" in the current directory,
you will need to search recursively.
example: grep -h 500 **/access.log*
expected_output:
order: false
lines:
- 69.16.40.148 - - [09/Jan/2017:22:34:33 +0100] "GET /pages/create HTTP/1.0" 500 3471
- 225.219.54.140 - - [09/Jan/2017:22:35:30 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 500 2477
- 2.71.250.27 - - [09/Jan/2017:22:41:26 +0100] "GET /pages/create HTTP/1.0" 500 2477
- slug: extract_ip_addresses
version: 4
author: cmdchallenge
description: |
Extract all IP addresses from files
that start with "access.log" printing one
IP address per line.
example: grep -Pho '^\d+\.\d+\.\d+\.\d+' **/access.log*
expected_output:
re_sub: ['^[\w/.]*?:', '']
order: false
lines:
- 163.56.115.58
- 75.113.188.234
- 69.16.40.148
- 225.219.54.140
- 207.243.19.2
- 199.37.62.156
- 55.74.240.123
- 251.111.109.143
- 101.163.230.250
- 200.19.168.148
- 108.68.174.15
- 17.2.20.139
- 28.151.137.59
- 199.150.241.179
- 2.71.250.27
- 17.137.186.194
- 151.84.119.34
- 4.180.204.195
- 9.230.96.54
- 157.143.233.21
- slug: delete_files
version: 5
author: cmdchallenge
description: |
Delete all of the files in this challenge
directory including all subdirectories and
their contents.
example: find . -delete
- slug: count_files
version: 6
author: cmdchallenge
description: |
Count the number of files in the current
working directory. Print the number of
files as a single integer.
example: find -L . -type f | wc -l
example_fail: echo 3
expected_output:
re_sub: ['^\s+', '']
lines:
- '3'
- slug: simple_sort
version: 4
author: cmdchallenge
disp_title: Sort lines in a file.
description: |
Print the contents of access.log
sorted.
example: sort access.log
expected_output:
lines:
- 101.163.230.250 - - [09/Jan/2017:22:52:31 +0100] "DELETE /posts/2/display HTTP/1.0" 404 2477
- 163.56.115.58 - - [09/Jan/2017:22:29:57 +0100] "GET /posts/2/display HTTP/1.0" 200 3240
- 199.37.62.156 - - [09/Jan/2017:22:42:18 +0100] "GET /posts/1/display HTTP/1.0" 200 2477
- 200.19.168.148 - - [09/Jan/2017:22:57:11 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 3471
- 207.243.19.2 - - [09/Jan/2017:22:38:03 +0100] "GET /bar/create HTTP/1.0" 200 1116
- 225.219.54.140 - - [09/Jan/2017:22:35:30 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 500 2477
- 251.111.109.143 - - [09/Jan/2017:22:49:02 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 2477
- 55.74.240.123 - - [09/Jan/2017:22:44:25 +0100] "POST /posts/1/display HTTP/1.0" 200 3471
- 69.16.40.148 - - [09/Jan/2017:22:34:33 +0100] "GET /pages/create HTTP/1.0" 500 3471
- 75.113.188.234 - - [09/Jan/2017:22:30:43 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 1116
- slug: count_string_in_line
version: 5
author: cmdchallenge
disp_title: Count Matching Lines.
description: |
Print the number of lines
in access.log that contain the string
"GET".
example: grep -c "GET" access.log
example_fail: echo 8
expected_output:
re_sub: ['^\s+', '']
lines:
- '8'
- slug: split_on_a_char
version: 4
author: cmdchallenge
disp_title: Split on a single character.
description: |
The file split-me.txt contains a list of
numbers separated by a ';' character.
Split the numbers on the ';' character,
one number per line.
example: tr ';' '\n' < split-me.txt
expected_output:
lines: ["1","2","3","4","5","6","7","8","9","10"]
- slug: print_number_sequence
version: 4
author: cmdchallenge
disp_title: Generate a number sequence.
description: |
Print the numbers 1 to 100 separated
by spaces.
example: echo $(seq 1 100)
expected_output:
lines:
- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
- slug: remove_files_with_extension
version: 4
author: cmdchallenge
disp_title: Remove files with extension.
description: |
There are files in this challenge with
different file extensions.
Remove all files with the .doc extension
recursively in the current working directory.
example: rm **/*.doc
- slug: replace_text_in_files
version: 4
author: cmdchallenge
disp_title: Replace text in files
example: sed -i 's/challenges are difficult//g' **/*.txt
description: |
This challenge has text files (with a .txt extension)
that contain the phrase "challenges are difficult".
Delete this phrase recursively from all text files.
Note that some files are in subdirectories so you will
need to search for them.
- slug: sum_all_numbers
version: 5
author: cmdchallenge
disp_title: Sum numbers in a file.
example: paste -sd+ sum-me.txt | bc
example_fail: echo 42
description: |
The file sum-me.txt has a list of numbers,
one per line. Print the sum of these numbers.
expected_output:
lines:
- "42"
- slug: just_the_files
version: 4
author: cmdchallenge
disp_title: Print only the filenames
description: |
Print all files in the current directory
recursively without the leading directory path.
example: find -type f -printf '%f\n'
expected_output:
order: false
lines:
- animi.doc
- corporis.xls
- odit.doc
- beatae.flac
- error.doc
- libero.xls
- necessitatibus.doc
- README
- totam
- slug: remove_extensions_from_files
version: 4
author: cmdchallenge
disp_title: Remove file extensions.
description: |
Rename all files removing the extension from
them in the current directory recursively.
example: for f in $(find . -type f -name "*.*"); do mv "$f" "${f%.*}"; done
- slug: replace_spaces_in_filenames
version: 4
author: cmdchallenge
disp_title: Replace spaces in file names.
description: |
The files in this challenge contain spaces.
List all of the files (filenames only) in the
current directory but replace all spaces with
a '.' character.
example: ls | tr ' ' '.'
expected_output:
order: false
lines: ['Adam.Simpson', 'Alexis.Stein', 'Allison.Brown', 'Amy.Anderson', 'Angel.Saunders',
'Brad.Michael', 'Briana.Wilson', 'Carrie.Alexander', 'Christine.Valdez', 'Christopher.Miller',
'Claudia.Mccormick', 'Corey.Bird', 'Courtney.Miller', 'Crystal.Dunn', 'Crystal.Valdez',
'Erica.Richardson', 'James.Harper', 'James.Roberts', 'Jared.Hill.DVM', 'John.Nguyen',
'Jorge.Ross', 'Joseph.Hurst', 'Karen.Ramirez', 'Kevin.Price', 'Kimberly.Parker', 'Lori.Macias',
'Luke.Mason', 'Lynn.Robinson', 'Mallory.Peterson', 'Marie.Gutierrez', 'Matthew.Romero',
'Michaela.Hobbs', 'Molly.Stevens', 'Mr..James.Lopez', 'Mr..Shawn.Martin', 'Mrs..Jade.Clark',
'Olivia.Irwin', 'Parker.Gilbert', 'README', 'Robert.Gregory', 'Robert.Hill', 'Sarah.Hill',
'Scott.Rice', 'Sheri.Bishop', 'Tamara.Anderson', 'Tammy.Galloway', 'Terri.Young', 'Thomas.Parks',
'Thomas.Washington', 'Tiffany.Clark', 'Yvonne.Myers']
- slug: dirs_containing_files_with_extension
version: 1
author: cmdchallenge
description: |
In this challenge there are some directories containing files
with different extensions. Print all directories,
one per line without duplicates that contain
one or more files with a ".tf" extension.
example: find . -name "*.tf" -type f -exec dirname {} \; | sort | uniq
expected_output:
order: false
re_sub: ['^\./', '']
lines:
- 'terraform'
- 'terraform/modules/load_balancer'
- 'terraform/modules/virtual_machine'
- 'terraform/modules/vpn'
- slug: files_starting_with_a_number
version: 4
author: cmdchallenge
disp_title: Print files starting with a number.
description: |
There are a mix of files in this directory
that start with letters and numbers. Print
the filenames (just the filenames) of all
files that start with a number recursively
in the current directory.
example: find . -type f -name '[[:digit:]]*' -printf '%f\n'
expected_output:
order: false
lines: ['974Michael Bowman', '540Katherine Jones', '436Teresa Owens', '04Carrie Alexander', '778Holly Archer',
'3maxime.mp3', '682Terri Jones', '511Tammy Welch', '293Linda Bennett', '670James Jacobs', '737Jeffrey Davis',
'42Robert Hill', '25Brandon Mcdonald', '402Nancy Henson', '78Michelle Spencer', '132Rebecca Rubio',
'639Charles Ferguson', '335John Joseph', '99blanditiis.avi', '477Thomas Pierce MD', '757Robert Marquez',
'388Andrew Carter', '48Thomas Allen', '593Brett Martin']
- slug: print_nth_line
version: 4
author: cmdchallenge
disp_title: Print the nth line.
description: |
Print the 25th line of the file faces.txt
example: sed -n '25p' faces.txt
expected_output:
lines: ['¯\_(ツ)_/¯']
- slug: reverse_readme
version: 4
author: cmdchallenge
disp_title: Reverse the README
description: |
Print the lines of the README file in this directory in
reverse line order so that the last line is printed first
and the first line is printed last.
~~~~~~~~~~~~~~~~~~~~~
In the future
Environmental destruction will be the norm
No longer can it be said that
My peers and I care about this earth
It will be evident that
My generation is apathetic and lethargic
It is foolish to presume that
There is hope
~~~~~~~~~~~~~~~~~~~~~
-Jonathan Reed "The Lost Generation"
example: tac README
expected_output:
lines:
- '# '
- '# -Jonathan Reed "The Lost Generation"'
- '# ~~~~~~~~~~~~~~~~~~~~~'
- '# There is hope'
- '# It is foolish to presume that'
- '# My generation is apathetic and lethargic'
- '# It will be evident that'
- '# My peers and I care about this earth'
- '# No longer can it be said that'
- '# Environmental destruction will be the norm'
- '# In the future'
- '# ~~~~~~~~~~~~~~~~~~~~~'
- '# and the first line is printed last.'
- '# reverse line order so that the last line is printed first'
- '# Print the lines of the README file in this directory in'
- ''
- '# **************'
- '# Reverse the README'
- slug: remove_duplicate_lines
version: 4
author: cmdchallenge
disp_time: Remove duplicate lines without sorting
description: |
Print the file faces.txt, but only print the first instance of each
duplicate line, even if the duplicates don't appear next to each other.
Note that order matters so don't sort the lines before removing duplicates.
example: awk '!x[$0]++' faces.txt
expected_output:
lines: ['(◕‿◕)', '(^̮^)', 'ʘ‿ʘ', 'ಠ_ಠ', 'ಠ⌣ಠ', 'ಠ‿ಠ', '(ʘ‿ʘ)', '(ಠ_ಠ)', '¯\_(ツ)_/¯',
'(ಠ⌣ಠ', 'ಠಠ⌣ಠ)', '(ಠ‿ಠ)', '٩◔̯◔۶', 'ヽ༼ຈل͜ຈ༽ノ', '♥‿♥', '◔̯◔', '⊙﹏⊙',
'(¬_¬)', '(;一_一)', '(͡° ͜ʖ ͡°)', '(° ͜ʖ °)', '¯\(°_o)/¯', '( ゚ヮ゚)', '(︺︹︺)']
- slug: disp_table
version: 1
author: cmdchallenge
disp_title: Displaying a table from a csv
description: |
The file "table.csv" contains the following comma-separated lines:
id,name,count
4,susan,11
33,alice,22
1772,joe,33
Print the rows as a table, like the following:
id name count
4 susan 11
33 alice 22
1772 joe 33
example: cat table.csv | column -t -s","
expected_output:
lines:
- id name count
- 4 susan 11
- 33 alice 22
- 1772 joe 33
- slug: find_primes
version: 1
author: cmdchallenge
example: 'for num in $(cat random-numbers.txt); do [[ $num == $(factor $num | cut -d" " -f2) ]] && echo $num; done | sort | uniq | wc -l'
example_fail: echo 12
disp_title: Finding prime numbers
description: |
The file random-numbers.txt contains a list
of 100 random integers. Print the number of
unique prime numbers contained in the file.
expected_output:
lines:
- "12"
- slug: corrupted_text
version: 4
author: cmdchallenge
disp_title: Removing extra '!' characters from text
example: perl -pne 's/!(?![ \n])//g;' war_and_peace.txt | perl -pne 's/(?<=[.])!//g' | perl -pne 's/!(?= [a-z])//g'
description: |
The following excerpt from War and Peace is saved to
the file 'war_and_peace.txt':
She is betraying us! Russia alone must save Europe.
Our gracious sovereign recognizes his high vocation
and will be true to it. That is the one thing I have
faith in! Our good and wonderful sovereign has to
perform the noblest role on earth, and he is so virtuous
and noble that God will not forsake him. He will fulfill
his vocation and crush the hydra of revolution, which
has become more terrible than ever in the person of this
murderer and villain!
The file however has been corrupted, there are random '!'
marks inserted throughout. Print the original text.
expected_output:
lines:
- She is betraying us! Russia alone must save Europe.
- Our gracious sovereign recognizes his high vocation
- and will be true to it. That is the one thing I have
- faith in! Our good and wonderful sovereign has to
- perform the noblest role on earth, and he is so virtuous
- and noble that God will not forsake him. He will fulfill
- his vocation and crush the hydra of revolution, which
- has become more terrible than ever in the person of this
- murderer and villain!
##########
# Start User Contributed Challenges
# ########
- slug: print_common_lines
version: 4
author: amboar
disp_title: Print common lines
example: "comm -12 <(cut -d' ' -f1 access.log.1 | sort) <(cut -d' ' -f1 access.log.2 | sort)"
description: |
access.log.1 and access.log.2 are http server logs. Print the IP
addresses common to both files, one per line.
expected_output:
order: false
lines:
- 108.68.174.15
- 17.137.186.194
- 2.71.250.27
- 28.151.137.59
- slug: print_line_before
version: 4
author: mmr
disp_title: Print line before match
example: "awk '/404/{print a}{a=$0}' **/access.log*"
description: |
Print all matching lines (without the filename
or the file path) in all files under the current
directory that start with "access.log", where
the next line contains the string "404". Note that
you will need to search recursively.
expected_output:
order: false
lines:
- 251.111.109.143 - - [09/Jan/2017:22:49:02 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 2477
- 17.137.186.194 - - [09/Jan/2017:22:43:17 +0100] "GET /pages/create HTTP/1.0" 200 1116
- 89.148.148.238 - - [09/Jan/2017:22:33:09 +0100] "GET /posts/1/display HTTP/1.0" 502 2477
- 138.212.253.84 - - [09/Jan/2017:22:53:54 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 200 3471
- slug: print_files_if_different
version: 4
author: anonymous
disp_title: Print files that are different
example: "for i in $(ls *.bin); do if [[ `cmp base.bin $i` ]]; then echo $i; fi; done"
description: |
Print all files with a .bin extension in the current directory
that are different than the file named base.bin.
expected_output:
order: false
lines:
- test2.bin
- test4.bin
- test5.bin
- test7.bin
- slug: list_files_adv
version: 4
author: gitunique
description: |
List all of the files in the current directory, display a slash (`/') immediately after
each pathname that is a directory, an asterisk (`*') after each that is executable,
an at sign (`@') after each symbolic link. Output one file per line.
Hint: directories are suffixed with '/', executables with '*'.
You will need to restrict the number of columns too.
example: ls -laF -C1
expected_output:
lines:
- './'
- '../'
- '.hidden-dir/'
- '.hidden-file'
- 'README'
- 'normal-file.dat'
- 'runthis.sh*'
- 'symlink-file.dat@'
- slug: nested_dirs
version: 5
author: gitunique
description: |
There is a file:
./.../ /. .the flag.txt
Show its contents on the screen.
example: cat ./.../\ \ /.\ .the\ flag.txt
example_fail: echo you got it!
expected_output:
lines:
- 'you got it!'
- slug: find_tabs_in_a_file
version: 5
author: anonymous
description: |
How many lines contain tab characters in
the file named "file-with-tabs.txt" in the
current directory.
example: grep -P '\t' file-with-tabs.txt | wc -l
example_fail: echo 3
expected_output:
lines:
- "3"
- slug: remove_files_without_extension
version: 4
author: bryfry
disp_title: Remove files without extension.
description: |
There are files in this challenge with
different file extensions.
Remove all files without the .txt and .exe extensions
recursively in the current working directory.
example: find . -type f -regextype posix-extended ! -regex ".*(\.txt|\.exe)$" -exec rm {} +
- slug: remove_files_with_a_dash
version: 4
author: anonymous
disp_title: Remove files that start with a dash
description: |
There are some files in this directory that
start with a dash in the filename.
Remove those files.
example: rm ./-*
- slug: print_sorted_by_key
version: 4
author: verovan
disp_title: Print the content sorted by PID
description: |
There are two files in this directory, ps-ef1 and ps-ef2.
Print the contents of both files sorted by PID and
delete repeated lines.
example: cat ps-ef1 > aux; sed '1 d' ps-ef2 >> aux; cat aux | sort -nk2,2 | uniq
expected_output:
lines:
- 'UID PID PPID C STIME TTY TIME CMD'
- 'root 1 0 0 mar04 ? 00:00:13 /sbin/init'
- 'root 2 0 0 mar04 ? 00:00:00 [kthreadd]'
- 'root 3 2 0 mar04 ? 00:01:07 [ksoftirqd/0]'
- 'user 5 2 0 mar04 ? 00:00:00 [kworker/0:0H]'
- 'user 7 2 0 mar04 ? 00:07:06 [rcu_sched]'
- 'user 8 2 0 mar04 ? 00:00:00 [rcu_bh]'
- 'root 9 2 0 mar04 ? 00:00:00 [migration/0]'
- 'root 10 2 0 mar04 ? 00:00:04 [watchdog/0]'
- 'user 11 2 0 mar04 ? 00:00:04 [watchdog/1]'
- 'root 12 2 0 mar04 ? 00:00:00 [migration/1]'
- 'root 13 2 0 mar04 ? 00:00:59 [ksoftirqd/1]'
- 'user 15 2 0 mar04 ? 00:00:00 [kworker/1:0H]'
- 'user 16 2 0 mar04 ? 00:00:04 [watchdog/2]'
- 'root 17 2 0 mar04 ? 00:00:00 [migration/2]'
- 'root 18 2 0 mar04 ? 00:00:59 [ksoftirqd/2]'
- 'root 20 2 0 mar04 ? 00:00:00 [kworker/2:0H]'
- 'user 21 2 0 mar04 ? 00:00:04 [watchdog/3]'
- 'root 22 2 0 mar04 ? 00:00:00 [migration/3]'
- 'root 23 2 0 mar04 ? 00:01:29 [ksoftirqd/3]'
- slug: IPv4_listening_ports
version: 4
author: TaTo69
description: |
In the current directory there is a file called netstat.out
print all the IPv4 listening ports sorted from the higher to lower.
example: egrep "tcp\ .*:**LISTEN" netstat.out | awk '{print $4}' | sed -e 's/.*\://g' | sort -nr
expected_output:
lines:
- '45922'
- '9090'
- '8080'
- '1723'
- '1254'
- '1244'
- '1234'
- '111'
- '80'
- '22'
- slug: rot13_decoding
version: 4
author: marrakchino
disp_title: Decoding a rot13 encoded file.
example: cat les_miserables.txt| tr '[A-Za-z]' '[N-ZA-Mn-za-m]'
description: |
The following excerpt from Victor Hugo's "Les miserables", is saved to
the file 'les_miserables.txt':
The glance of women resembles certain combinations of wheels, which are
tranquil in appearance yet formidable. You pass close to them every day,
peaceably and with impunity, and without a suspicion of anything.
A moment arrives when you forget that the thing is there.
You go and come, dream, speak, laugh. All at once you feel yourself
clutched; all is over. The wheels hold you fast, the glance has
ensnared you. It has caught you, no matter where or how, by some portion
of your thought which was fluttering loose, by some distraction which
had attacked you. You are lost.
However, the file was encoded using rot13. Print the original content
of the excerpt.
expected_output:
lines:
- The glance of women resembles certain combinations of wheels, which are
- tranquil in appearance yet formidable. You pass close to them every day,
- peaceably and with impunity, and without a suspicion of anything.
- A moment arrives when you forget that the thing is there.
- You go and come, dream, speak, laugh. All at once you feel yourself
- clutched; all is over. The wheels hold you fast, the glance has
- ensnared you. It has caught you, no matter where or how, by some portion
- of your thought which was fluttering loose, by some distraction which
- had attacked you. You are lost.