sh 将SSH密钥复制到远程服务器

这将登录到服务器主机,并将密钥复制到服务器,并通过将它们添加到authorized_keys文件来配置它们以授予访问权限。复制可能要求服务器的密码或其他身份验证。

ssh-copy-id-remote.sh
ssh-copy-id -i ~/.ssh/mykey user@host

sh 检查PostgreSQL连接

用于在RDS中应用修改时测试停机时间

test-psql-connectivity.sh
while true; do
  date -Isec | sed -e 's/+00:00//' | tr '\n' ' '
  pg_isready -h YOUR_RDS_INSTANCE.rds.amazonaws.com -U core -d core_production
  sleep 1
done | tee connection-test-$(date -Imin).log

sh 存储的make_erd命令

make_erd_commands.sh
#-- GR database, removing _version tables
python make_erd.py -d ngis_genomicrecord_beta -i 10.5.66.12 -p 5432 -u ngis_data_quality -x address_version alembic_version attachment_version cdr_author_version cdr_content_version cdr_relates_to_version clinical_ethnicity_version clinician_version condition_version consent_document_reference_version consent_note_version consent_organisation_version consent_questionnaire_response_version consent_questionnaire_version consent_version consent_witness_version consenting_party_version contact_version cq_item_enable_when_version cq_item_option_version cq_item_version cqr_answer_version cqr_author_version cqr_based_on_version cqr_item_version db_version identifier_version observation_component_version observation_version organisation_consent_version patient_version person_version procedure_request_version referral_additional_clinician_version referral_attachment_version referral_panel_version referral_participant_attachment_version referral_participant_version referral_sample_version referral_test_target_region_version referral_test_target_variant_version referral_test_version referral_version related_person_version sample_version sequence_status_version telecom_version tumour_description_version tumour_lab_result_version tumour_morphology_version tumour_topography_version tumour_version -w ngis_data_quality -o ~/scratch/gr.pdf 

sh 如何使用整数?

how_to_works_with_integers.js
NumberInt(number)
// example
NumberInt(15)

sh 192.168.0.32 - 打开端口

mac-mini.local.open-ports.zsh
Starting Nmap 7.80 ( https://nmap.org ) at 2019-09-10 10:06 MDT
Nmap scan report for mac-mini.local (192.168.0.32)
Host is up (0.000068s latency).
Other addresses for mac-mini.local (not scanned): fe80::cdc:a1b2:9cda:5054
Not shown: 982 closed ports
PORT      STATE SERVICE
21/tcp    open  ftp
22/tcp    open  ssh
80/tcp    open  http
88/tcp    open  kerberos-sec
111/tcp   open  rpcbind
445/tcp   open  microsoft-ds
464/tcp   open  kpasswd5
548/tcp   open  afp
625/tcp   open  apple-xsrvr-admin
749/tcp   open  kerberos-adm
1021/tcp  open  exp1
1023/tcp  open  netvenuechat
2049/tcp  open  nfs
3031/tcp  open  eppc
3283/tcp  open  netassistant
3306/tcp  open  mysql
5900/tcp  open  vnc
49155/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 10.43 seconds

sh 命令行选项

options in bash.sh
  while getopts :r:l:p:o:q:t: name
   do
     case $name in
        l) LOG="$OPTARG" ;;        # LOG FILE
        p) PROC="$OPTARG" ;;       # Process name
        o) ONE_UP="$OPTARG" ;;     # One_Up Number
        q) PRNT="$OPTARG" ;;       # q Print queue 'FTP' for now
        r) LIS="$OPTARG" ;;        # lis file name
        t) FTPDEST="$OPTARG" ;;    # D = Disk, T = Tape
        *) Usage ;;                # display usage and exit
     esac
   done


# usage
# ,/scriptName.sh -l someFileName -p someProcessName

sh linux使用tr在同一行中打印多行输出

tr_multiple_lines_into_one.sh
ps -c -eo pid,ppid,cmd,%cpu --sort=-%cpu | head | grep -P "^\d+|^\s+\d+" | awk '{print $3,$4}' | tr "\n" " | "

sh 纱线改变dir

yarn.sh
yarn config set global-folder C:\ProgramData\yarn\data\global
yarn global dir
yarn config set prefix ~/.yarn
yarn global bin

# https://github.com/mixonic/docs.npmjs.com/blob/master/content/getting-started/fixing-npm-permissions.md

sh vscode扩展

vscode-extensions.sh
code --list-extensions | xargs -L 1 echo code --install-extension

sh OS检测shell代码

os-detect.sh



#detect the platform
OS="`uname`"
case $OS in
  Linux)
    OS='linux'
    ;;
  FreeBSD)
    OS='freebsd'
    ;;
  NetBSD)
    OS='netbsd'
    ;;
  OpenBSD)
    OS='openbsd'
    ;;  
  Darwin)
    OS='osx'
    ;;
  SunOS)
    OS='solaris'
    echo 'OS not supported'
    exit 2
    ;;
  *)
    echo 'OS not supported'
    exit 2
    ;;
esac

OS_type="`uname -m`"
case $OS_type in
  x86_64|amd64)
    OS_type='amd64'
    ;;
  i?86|x86)
    OS_type='386'
    ;;
  arm*)
    OS_type='arm'
    ;;
  aarch64)
    OS_type='arm64'
    ;;
  *)
    echo 'OS type not supported'
    exit 2
    ;;
esac