Filter lines from a file based on a specific condition, sort them, count unique occurrences, and save the top results to a new file.
The corresponding Unix command for this task is: awk -F';' ' $3 == "empt" ' test.txt | sort -r -k 2 | uniq -c | head -n 50 > newFile.txt
Remove duplicate lines from a file and then sort the remaining lines.
The corresponding Unix command for this task is: sort inputFile.txt | uniq > outputFile.txt
Filter rows containing the word "error" in a log file. Then count the number of lines that contain the word "error."
The corresponding Unix command for this task is: grep "error" logFile.txt | wc -l
Use a regex pattern that matches strings starting with an alphanumeric character, followed by any character one or more times, includes zero or more occurrences of a specific pattern and ends with a digit.
The corresponding Unix command for this task is: ^[[:alnum:]].*(example_pattern){0,}.*[[:digit:]]$
Extract and count domain names from a list of URLs and save the top 15 most frequent domains to a new file.
The corresponding Unix command for this task is: awk -F'/' ' -F'/' {print $3}}' ' urls.txt | sort | uniq -c | sort -r | head -n 15 > topdomains.txt
Concatenate the contents of multiple files into a single file.
The corresponding Unix command for this task is: cat file1.txt file2.txt file3.txt > combinedFile.txt
Extract columns 1 and 3 from a CSV file and save the output to a new file.
The corresponding Unix command for this task is: cut -d ',' -f 1,3 file1.txt > combinedFile.txt
Use the awk command to calculate the sum of sales for each year and the total sales across all years from a .txt file.
The corresponding Unix command for this task is: awk -F';' ' BEGIN {total = 0; } {i = 1; while (i <= NR) { sum = 0; j = 1; while (j <= NF) { sum += $j; j ++; } total += sum; print("Sum of row",NR,":",sum); i ++; } } END {print("Total Sum:",total); } ' test.txt