Skip to content

This repository is for the for all the solutions and read-ups for the command line challenge.

Notifications You must be signed in to change notification settings

nihilistdbanana/CMD-Challenge-Solutions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

CMD-Challenge-Solutions

This repository is for the for all the solutions and read-ups for the command line challenge. Since the challenges are one liners so with the solutions the following info on the command will be updated.

Link to the challenge: https://cmdchallenge.com/

Challenges and Solutions

Question 1 - Print "hello world".

Command: echo

Description: Echo the STRING(s) to standard output.

echo "hello world" 

Question 2 - Print the current working directory.

Command: pwd

Description: Print the full filename of the current working directory.

pwd

Question 3 - List names of all the files in the current directory.

Command: ls

Description: List information about the FILEs (the current directory by default)

ls 

Question 4 - There is a file named "access.log" in the current directory. Print the contents.

Command: cat

Description: Concatenate FILE(s), or standard input, to standard output.

cat

Question 5 - Print the last 5 lines of "access.log".

Command: tail

Description: Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input.

tail -5 access.log

Question 6 - There is a file named "access.log" in the current working directory. Print all lines in this file that contains the string "GET".

Command: grep

Description: grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.

grep "GET" access.log

Question 7 - Print all files in the current directory,one per line (not the path, just the filename) that contain the string "500".

Command: grep

Description: grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.

grep -l 500 *

Question 8 - Print the relative file paths, one path per line for all filenames that start with "access.log" in the current directory.

Command: ls

Description: List information about the FILEs (the current directory by default)

ls access.log*

About

This repository is for the for all the solutions and read-ups for the command line challenge.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published