Created
January 30, 2017 22:03
-
-
Save shollingsworth/7ee0572274e42af97df156cea1f3ca2d to your computer and use it in GitHub Desktop.
cmdchallenge.com solutions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello_world/ | |
echo "hello world" | |
current_working_directory/ | |
pwd | |
list_files/ | |
ls | |
print_file_contents/ | |
cat access.log | |
last_lines/ | |
tail -n5 access.log | |
find_string_in_a_file/ | |
grep 'GET' access.log | |
find_tabs_in_a_file/ | |
grep -P '\t' file-with-tabs.txt | wc -l | |
search_for_files_containing_string/ | |
grep -rli '500' * | |
search_for_files_by_extension/ | |
find -type f -name 'access.log*' | |
search_for_string_in_files_recursive/ | |
find -type f -name 'access.log*' | xargs -I{} cat {}|grep '500' | |
extract_ip_addresses/ | |
find -type f -name 'access.log*' | xargs awk '{print $1}' | |
delete_files/ | |
find . -delete | |
count_files/ | |
find -type f | wc -l | |
simple_sort/ | |
sort access.log | |
count_string_in_line/ | |
grep 'GET' access.log|wc -l | |
split_on_a_char/ | |
cat split-me.txt | tr ';' '\n' | |
print_number_sequence/ | |
seq 1 100 | tr '\n' ' ' | |
remove_files_with_a_dash/ | |
find -type f -name '-*' -delete | |
remove_files_with_extension/ | |
find -type f -name '*.doc' -delete | |
remove_files_without_extension/ | |
find -type f \! -name '*.txt' -a \! -name '*.exe' -delete | |
replace_text_in_files/ | |
find -type f -name '*.txt' | xargs -I{} sed -i 's/challenges are difficult//g' "{}" | |
sum_all_numbers/ | |
z=0; for i in $(cat sum-me.txt); do z=$(($z + $i)); done; echo $z | |
just_the_files/ | |
find -type f | xargs -I{} basename "{}" | |
remove_extensions_from_files/ | |
for f in $(find -type f); do bn=${f%.*}; test -z "${bn}" || mv ${f} ${bn}; done | |
replace_spaces_in_filenames/ | |
find -type f | while read i; do echo "${i}" | sed 's&^./&&;s& &.&g'; done | |
files_starting_with_a_number/ | |
find -type f -name '[0-9]*' | xargs -I{} basename "{}" | |
print_nth_line/ | |
sed '25q;d' faces.txt | |
remove_duplicate_lines/ | |
#needed help on this | |
awk '!x[$0]++' faces.txt | |
corrupted_text/ | |
sed 's/!\+/!/g;s/!\([a-zA-Z]\)/\1/;s/\([a-z]\)!\([a-z]\)/\1\2/;s/! \([a-z]\)/ \1/;s/!\.!/./' war_and_peace.txt | |
print_common_lines/ | |
comm -1 -2 <(sort access.log.1 | awk '{print $1}') <(sort access.log.2 | awk '{print $1}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment