Get the App
SLTechnology News&Howtos  ›  Network Security  › 

SHELL script learning

Shulou Source: shulou.com Published: 2022-06-01 01:10:03 11月25日 Update

I. print string length

As follows, print the following words with no more than 6 letters

She could see the open door of a departmental office.

Vim print-str.sh

#! / bin/bash

# number of print strings

# the first solution

For i in She could see the open door of a departmental office

Do

[${# I}-le 6] & & echo $I

Done

Echo + +

# the second solution

For i in She could see the open door of a departmental office

Do

[`echo $I | wc-L`-le 6] & & echo $I

Done

Echo + +

# the third solution

Echo "She could see the open door of a departmental office" | awk'{for

Tags: Character string right byte idea function extension file symbol value keyboard length script maximum minimum two number position colon word Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei macOS NVidia vpn