Mes réponses à https://cmdchallenge.com/
Go to file
Clement Desmidt ab0f2769fb 📝 Corrige une typo 2017-02-13 11:59:33 +01:00
README.md 📝 Corrige une typo 2017-02-13 11:59:33 +01:00

README.md

Nom challenge Énoncé Réponse
hello_world/ Print "hello world". echo "hello world"
current_working_directory/ Print the current working directory. pwd
list_files/ List names of all the files in the current directory, one file per line. ls
list_files_advanced/ 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.
nested_dir ./.../ /. .the flag.txt Show its contents on the screen. cat "./.../ /. .the flag.txt"
print_file_contents/ There is a file named "access.log" in the current directory. Print the contents. cat access.log
last_lines/ Print the last 5 lines of "access.log". tail -n 5 access.log
find_string_in_a_file/ There is a file named "access.log" in the current working directory. Print all lines in this file that contains the string "GET". grep "GET" access.log
find_tabs_in_a_file/ How many lines contain tab characters in the file named "file-with-tabs.txt" in the current directory. grep -c -P '\t' file-with-tabs.txt
search_for_files_containing_string/ Print all files in the current directory, one per line (not the path, just the filename) that contain the string "500". grep -l 500 *
search_for_files_by_extension/ Print the relative file paths, one path per line for all filenames that start with "access.log" in the current directory. `ls
search_for_string_in_files_recursive/ 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. find . -type f -name "access.log*" -exec grep -hP '500' {} \;
extract_ip_addresses/ Extract all IP addreses from files that start with "access.log" printing one IP address per line. find . -type f -name "access.log*" -exec grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' {} \;
delete_files/
count_files/
simple_sort/ Print the contents of access.log sorted. `cat access.log
count_string_in_line/
split_on_a_char/
print_number_sequence/
remove_files_with_a_dash/ There are some files in this directory that start with a dash in the filename. Remove those files. rm -- -*rm
remove_files_with_extension/ There are files in this challenge with different file extensions. Remove all files with the .doc extension recursively in the current working directory. find . -type f -name "*.doc" -exec rm {} \;
remove_files_without_extension/
replace_text_in_files/ 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. find . -type f -name "*.txt" -exec sed -i 's/challenges are difficult//g' {} \;
sum_all_numbers/
just_the_files/ Print all files in the current directory recursively without the leading directory path. find . -type f -exec basename {} \;
remove_extensions_from_files/
replace_spaces_in_filenames/
files_starting_with_a_number/
print_nth_line/
remove_duplicate_lines/
corrupted_text/
print_common_lines/