Shell text Align left and right "go"

Source: Internet
Author: User

Text-to-left-aligned typography has text 4.txt as follows:

111111111111111111111 98912 Zhang Three
222222222222222222 150020 Lee 44
333333333333333333333 360000 Harry
444444444444444444 2332 Zhao 66
555555555555555555 222 Tianqi
666666666666666666666 999999

Simple text is formatted by batch processing

Writing code
#! /bin/bashfile=./4.txtEcho- e "\ n left-aligned \ n" While the read line does  printf "%-30s%-10d%-10s\n" ${line} Done < ${file}Echo- e "\ n right-align \ n" While the read line does  printf "%30s%10d %10s\n " ${line} done< ${file}           

Run results

Turn from

Text-to-left-align typesetting--shell-csdn blog
77800546

Shell text Align left and right "go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.