Command of the day (16 Nov) - cut

codlinuxcut

cut - Extract fields/columns

    cut -d. -f1 file : Extract first field (separated by dots) in each line of file

    cat file | cut -b1-5 : Extract bytes 1 to 5. Works on binary files

    cut -d, -f1,3 file: Extract fields 1 and 3 from a CSV file

    echo "token=abc123xyz" | cut -d= -f2 : Token extraction

    ls -l | tr -s ' ' | cut -d' ' -f1,9: Select permissions and file name from directory listing

 

Get your free ebook

Learn GNU/Linux one command a day

Return to Home Page