bash를 사용하여 파일의 텍스트 축소

bash를 사용하여 파일의 텍스트 축소

내 텍스트 파일은 다음과 같습니다.

If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definitive operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using any major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, TVs, automobiles, and many other devices.

축소하고 싶어서 이렇게 생겼어요

If you are a software developer in your 20s or 30s, 
you've grown up in a world dominated by Linux. It ha
s been a significant player in the data center for d
ecades, and while it's hard to find definitive opera
ting system market share reports, Linux's share of d
ata center operating systems could be as high as 70%
, with Windows variants carrying nearly all the rema
ining percentage. Developers using any major public 
cloud can expect the target system will run Linux. E
vidence that Linux is everywhere has grown in recent
 years when you add in Android and Linux-based embed
ded systems in smartphones, TVs, automobiles, and ma
ny other devices.

그런 다음 확대하면 다음과 같습니다.

If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definiti
ve operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using a
ny major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, 
TVs, automobiles, and many other devices.

어떻게 해야 하나요? 스크립트에 포함시켜야 합니다.

답변1

다음 명령을 사용할 수 있습니다.다음과 같이:

fold -w 

w포함된 열 수에 따라 접기 제어 텍스트(축소 및 확장) 명령의 플래그입니다 .

귀하의 예에서 :

fold -w 52 file 

그리고

fold -w 200 file

답변2

다음 명령을 사용할 수 있습니다.

sed 's/.\{80\}/&\n/g' file

80은 한 줄에 포함하려는 문자 수이고 file텍스트를 저장하는 파일은 어디에 있습니까?

.\{80\}- 정규식은 정확히 80자와 일치합니다.

&\n- \n일치하는 텍스트에 추가

관련 정보