What do you want to save?
Add Code snippet
New code examples
-
Shell/Bash 2021-08-29 16:41:01
bash remove duplicate lines from a file
# Basic syntax: sort input_file | uniq --unique # Sort the file first because uniq requires a sorted file to work. Uniq # then eliminates all duplicated lines in the file, keeping one instance # of each duplicated line # Note, this doesn't return only no... Add solution -
Shell/Bash 2021-08-29 11:20:01
bash return unique lines starting at nth field
# Basic syntax: uniq -f number input_file # Where number specifies the number of fields/columns to ignore from left # to right when doing comparisons to return unique lines # Note, uniq requires a sorted input. You can sort a file based on # specific f... Add solution -
Python 2021-08-29 05:42:02
python sort two key
s = sorted(s, key = lambda x: (x[1], x[2])) Add solution -
Shell/Bash 2021-08-28 14:31:02
bash get one checksum for many files
# Basic syntax: find /directory/to/search -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum > single_md5sum.txt # Where: # - find -type f returns all files (but not directories) in # /directory/to/search and its subdirectories # - -exec m... Add solution -
Shell/Bash 2021-08-28 09:52:02
bash remove rows that are found in another file
# Example usage using awk: awk 'FNR==NR { b[$0] = 1; next } !b[$0]' input_file_1 input_file_2 # This command prints all lines of input_file_2 that aren't found in # input_file_1 (i.e. lines that are unique to input_file_2). Another # way of saying this is... Add solution -
Shell/Bash 2021-08-28 05:39:02
bash list the top ten largest values in a column
# Example usage: sort -k3n,3 input_file | tail -10 # Here we sort the input_file in numerical order based on the third # field and then pipe to tail to print the last ten rows. # If you only want to return specific fields from the sorted file, pipe # t... Add solution -
Shell/Bash 2021-08-27 17:35:02
bash print lines unique to one file
# Example usage using awk: awk 'FNR==NR { b[$0] = 1; next } !b[$0]' input_file_1 input_file_2 # This command prints all lines of input_file_2 that aren't found in # input_file_1 (i.e. lines that are unique to input_file_2). Another # way of saying this is... Add solution