Txheeb: Hloov kab ntawv ntawm kab ntawv rau ib kab

Piv txwv peb muaj cov ntawv sau hu ua distros.txt nrog rau cov hauv qab no:

archlinux
debian
ubuntu
kaws
fedora
slackware
neeg

Thiab peb xav tig mus rau hauv:

archlinux debian ubuntu kaos fedora slackware gentoo

Yuav kom ua tiav qhov no peb yuav siv a rau lub voj thiab ncha -n :

for i in `< distros.txt`; do echo -n ${i}" ";done; echo ""

Ua li cas, qhov no ua qhov dag trick

Qhov no yuav qhia peb cov txiaj ntsig xav tau nyob rau hauv lub davhlau ya nyob twg, yog tias ntawm qhov tod tes peb xav kom nws tau txais kev cawm dim nyob rau hauv lwm .txt cov ntaub ntawv peb rov tsim tawm:

for i in `< distros.txt`; do echo -n ${i}" ";done; echo "" > distros-nuevas.txt

Thiab voila 🙂

Zoo tsis muaj dab tsi, Kuv vam tias koj pom tias nws muaj txiaj ntsig. Siv tau qhov tseeb tias nws tseem yuav ua tau nrog cov kab lus ib txwm, Kuv tsuas yog tsis paub yuav ua li cas ... tab sis, nrog cov kab lus ib txwm koj tuaj yeem ua yuav luag txhua yam hahaha.


Cov ntsiab lus ntawm tsab xov xwm ua raws li peb cov ntsiab cai ntawm kev tswj hwm kev ncaj nceesCov. Tshaj tawm ib qho yuam kev nyem no.

15 lus, tawm koj li

Tso koj saib

Koj email chaw nyob yuav tsis tsum luam tawm. Yuav tsum tau teb cov cim nrog *

*

*

  1. Lub luag haujlwm rau cov ntaub ntawv: Miguel Ángel Gatón
  2. Lub hom phiaj ntawm cov ntaub ntawv: Tswj SPAM, kev tswj xyuas tawm tswv yim.
  3. Sau raws cai: Koj kev tso cai
  4. Kev sib txuas lus ntawm cov ntaub ntawv: Cov ntaub ntawv yuav tsis raug xa mus rau lwm tus neeg thib peb tsuas yog los ntawm kev txiav txim siab raug cai.
  5. Cov ntaub ntawv khaws cia: Cov Ntaub Ntawv khaws tseg los ntawm Occentus Networks (EU)
  6. Txoj Cai: Txhua lub sijhawm koj tuaj yeem txwv, rov qab thiab tshem tawm koj cov ntaub ntawv.

  1.   Jose Ricardo said

    yooj yim dua:

    miv distros.txt | xargs -n 100

  2.   ¿ said

    Yog tias nyob hauv ib qho .odt Kuv muaj 2 kab ntawv ntawm txhua nplooj ntawv, lawv nyeem zoo li no:

    p. 1
    col.1 col.2
    p. 2
    col.3 col.4
    thiab lwm yam

    Yuav ua li cas Kuv thiaj li tau txais txhua kem hauv qab?
    coj 1
    coj 2
    coj 3
    coj 4
    thiab lwm yam

  3.   yuag said

    Yooj yim dua:

    Yog tias koj xav tau cais los ntawm tabs:
    Koj sau: muab tshuaj -s distros.txt
    Koj tau txais: archlinux debian ubuntu kaos fedora slackware gentoo

    Yog tias koj xav tau nws cais los ntawm tej qhov chaw:
    Koj sau: paste -s -d »» distros.txt
    Koj tau txais: archlinux debian ubuntu kaos fedora slackware gentoo

    Yog tias koj xav tau nws cais los ntawm commas:
    Koj sau: paste -s -d, distros.txt
    Koj tau txais: archlinux, debian, ubuntu, kaos, fedora, slackware, gentoo

    Nrog muab tshuaj txhuam, miv, awk thiab lwm tus phooj ywg, nrog me ntsis ingenuity koj tuaj yeem ua ntau yam tseem ceeb sib xyaw ua ke yam tsis muaj teeb meem rau koj lub neej.

    Cia txhua yam mus txuas ntxiv, zoo siab nrog rau qhov khoom plig hauv Portalprogramas!

    1.    dhunter said

      Kuv tau siv sed, awk, txiav, tsi, uniq, nyob rau luv luv qab zib, tab sis kuv ib txwm tsis them sai sai los muab tshuaj txhuam, ua tsaug rau qhov uas nws tuaj yeem ua. Slds.

  4.   Tabris said

    miv file.txt | xargs

    nyiaj.

  5.   Cristianhcd said

    Kuv ib txwm mus siv kom ua tau zoo rau qhov no [transpose] ... pab tau zoo heev

  6.   Bruno cascio said

    Lwm yam txawv:

    miv distros.txt | tr «\ n» »

  7.   Joaquin said

    HaHaHa hauv txhua qhov kev tawm tswv yim, txoj kev sib txawv ntawm kev ua ib yam!

  8.   Jose GDF said

    Thiab ua qhov fab ntxeev, nws yuav zoo li cas? Ntawd yog, hloov kab ntawm cov lus sib cais los ntawm qhov chaw mus rau hauv ib kem.

    1.    yuag said

      Yooj yim dhau, lub sijhawm no nrog awk.
      Xav tias cov teb tau sib cais los ntawm tabs lossis qhov chaw, uas yog qhov muaj ntau tshaj plaws (yog tias nws yog los ntawm commas lossis lwm yam, nws yuav tsum raug coj mus rau hauv tus account thiab qhia), thiab cov ntaub ntawv tam sim no muaj: archlinux debian ubuntu kaos fedora slackware gentoo

      Txij li thaum awk ncaj qha muab peb cov teb peb xav tau, peb yuav tsum ua nws iteratively qhia peb ib qho los ntawm ib txog thaum kawg. Muaj 7 daim teb vim qhov no yog tus nqi ntawm NF (Tus naj npawb ntawm cov teb). Peb teeb lub txee i = 1, kom nws qhia peb thawj daim teb ($ 1) thiab peb yuav tsum tau txais nws nce los ntawm ib chav (siv i ++) yam tsis dhau lub nras kawg (NF).

      awk '{rau (i = 1; Kuv <= NF; kuv ++) {luam $ i}}' distros.txt

      1.    Etemenanki said

        Txoj kev ua tau yooj yim tshaj plaws, yooj yim kom nco qab thiab uas ua haujlwm rau ob qho kev hnov ​​yog qhov no:
        miv distros.txt | tr '\ n' '' ← Tso zis stdout tso zis (Twb tau tham los saum no)
        miv distros.txt | tr '' '\ n' output Tso zis stdout Ntsug

        Ua tsaug!

    2.    yuag said

      Qhov tseeb Etemenanki txoj kev daws teeb meem, ob txoj hauv kev, yog qhov zoo yog tias koj tsuas yog xav nyob rau hauv kev hloov pauv yooj yim los ntawm kab mus rau kem thiab rov ua lwm yam.

    3.    Jose GDF said

      Ua tsaug rau txhua tus teb. Kuv yuav muab coj los siv rau hauv cov ntawv tom ntej uas kuv ua.

      Txais tos.

  9.   Miv said

    Thiab yog tias koj tsuas yog ua:
    ncha $ (miv distros.txt)

  10.   Anson rodriguez said

    Txawm yooj yim:
    awk '{printf $ 0 ″ «}' distros.txt