Ungayisusa kanjani imigqa ethile kusuka kufayela usebenzisa i-sed

Ngezikhathi ezithile sidinga ukususa umugqa othile kufayela noma eziningana, ngokwesibonelo, kwenzeke kimi ukuthi ngibe nohlu lwamafayela lonke futhi ngidinga ukususa umugqa # 27 wakho konke lokhu (umugqa # 27 yilokho ye-ACL, ejwayelekile, yokubusa, yokumisa), ngingahlela ifayela ngefayela noma ngingavele ngifeze engikudingayo ngisebenzisa umyalo sed nombhalo we-bash (ongakukhetha).

Kepha, ake sizame ifayela elilodwa ngandlela thile elilula.

Sinefayela distros-deb.txt okuqukethe lokhu:

debian

kubuntu

archlinux

ama-soluses

Mint

Ngamanye amagama, i- file distros-deb.txt lapho sizobeka khona ama-distros asuselwa ku-Debian, kepha lapho sibona ukuthi kulayini # 3 kukhona i- "archlinux", i-distro okusobala ukuthi ayihlangene noDebian, ngakho-ke kufanele siwususe lowo mugqa. Ukususa umugqa # 3 walelo fayela sizobeka okulandelayo:

sed "3d" distros-deb.txt > distros-deb-ok.txt

Ukuchaza lo mugqa kulula, nge omile "3d" sikhombisa ukuthi sizosusa umugqa # 3, nge distros-deb.txt Sikhomba ukuthi yiliphi ifayela okufanele lisebenze kulo, okungukuthi, susa umugqa # 3 waleli fayela, kuze kufike lapha uma sicindezela u- Enter lizosikhombisa esikufunayo kodwa esigungwini, ngakho-ke > distros-deb-ok.txt sikhombisa ukuthi esikhundleni sokukhombisa umphumela ku-terminal, ukuthi wawubeka kufayela elinaleli gama.

Yini elula?

Futhi, singakugwema ukusebenzisa i- > distros-deb-ok.txt kusetshenziswa ipharamitha efanelekile ye- sed, ipharamitha -i

Lokho wukuthi, uma kwenzeka sifuna ukususa umugqa kufayela bese siligcina ngegama elifanayo (hhayi kwelinye ifayili), mane ungeze ipharamitha -i :

sed -i "3d" distros-deb.txt

Lokhu kuzosusa umugqa # 3 kusuka ku-distros-deb.txt bese ukugcina.

Kuthiwani uma ngifuna uhla lwemigqa, okungukuthi ukususa umugqa # 3 kepha futhi # 4 no # 5? Ukufeza lokhu sibeka ibanga kusuka ku-3 kuye ku-5, okungukuthi:

sed -i "3,5d" distros-deb.txt

Futhi izongikhombisa kuphela i-debian ne-kubuntu 😀

Ngakho-ke kuthiwani uma ngifuna ukususa kusuka kulayini 2 kuye kowokugcina, lapho angazi imigqa ephelele?

Vele usebenzise uphawu lwedola - »$

sed -i "2,$d" distros-deb.txt

Uma kwenzeka ufuna ukususa kulayini wokuqala uye ku- # 4 bese simane sibeka inani elingu-1 ekuqaleni:

sed -i "1,4d" distros-deb.txt

Lokhu bekulokhu kuyikho konke, ithiphu elilusizo kakhulu lapho ufuna ukwenza imibhalo ye-bash ukwenza imisebenzi futhi udinga ukuguqula futhi uqede imigqa yamafayela wokumisa, ukuguqula esingakusebenzisa sed o i-perl, kanye nokuqeda sesivele sazi ukuthi singakwenza kanjani nge-sed 😉

Phendula ngokucaphuna


Okuqukethwe yi-athikili kunamathela ezimisweni zethu ze izimiso zokuhlelela. Ukubika iphutha chofoza lapha.

Amazwana ayi-16, shiya okwakho

Shiya umbono wakho

Ikheli lakho le ngeke ishicilelwe. Ezidingekayo ibhalwe nge *

*

*

  1. Ubhekele imininingwane: Miguel Ángel Gatón
  2. Inhloso yedatha: Lawula Ugaxekile, ukuphathwa kwamazwana.
  3. Ukusemthethweni: Imvume yakho
  4. Ukuxhumana kwemininingwane: Imininingwane ngeke idluliselwe kubantu besithathu ngaphandle kwesibopho esisemthethweni.
  5. Isitoreji sedatha: Idatabase ebanjwe yi-Occentus Networks (EU)
  6. Amalungelo: Nganoma yisiphi isikhathi ungakhawulela, uthole futhi ususe imininingwane yakho.

  1.   mss-devel kusho

    Umnikelo omuhle kakhulu 😉

    1.    KZKG ^ Gaara kusho

      Siyabonga 🙂

      Ngendlela, siyitholile i-imeyili yakho njengamanje ngizokuphendula 😀

      Phendula ngokucaphuna

  2.   ongenagama kusho

    Njengompristi ophakeme we-terminal, amaseva nokuxhumana kwe-ssh ngiza kuwe, oh KZKG ^ Gaara, futhi ngiyakubuza: ngingasitholaphi isifundo ezingeni lokungazi kwami ​​okungivumela ukuthi ngisebenzise ukuxhumana kwe-ssh phakathi kwemishini emibili ekude kumanethiwekhi ahlukene ukwabelana ngamafayela wombhalo, i-pdf, isithombe nomsindo (mp3)….

    🙂

    Ngokuzimisela, ungangiqondisa kulokhu, nginemishini emibili, owodwa emsebenzini nowodwa ekhaya futhi ngidinga ukuxhumana kwe-ssh phakathi kwabo (ngoba njengoba ngikuqonda, i-ssh ivumela okuqukethwe ukuthi kwabelwane ngakho phakathi kwemishini, ngiqinisile? ).
    Futhi uma nginephutha, yisiphi isicelo osincomayo?
    Futhi ngisitholaphi isifundo esiyisisekelo kulokhu?

    1.    -skyker- kusho

      scp.

      scp user @ machine_address: indlela yomsebenzisi @ machine_address: path.

      I-syntax efanayo ne-cp, umthombo -> ukuphela.

  3.   F3niX kusho

    Ukhombisile ndoda, ubulahlekile.

  4.   Joaquin kusho

    Ithiphu enhle!

  5.   LycusHackerEmo kusho

    Ithiphu enesithakazelo… xD

    Ngabe kukhona owaziyo okwenza umbhalo ogqamile ugqame?
    Ngiqonde ukuthi, nginefayela le-txt okuyisichazamazwi, linemigqa engaphezu kuka-10000 XNUMX futhi ngifuna liqhakambise umbhalo othile ngaphambi kwamaphoyinti wokumiswa we ":" futhi ukuwenza ngamunye ngamunye kukhulu kakhulu.

    1.    KZKG ^ Gaara kusho

      Sawubona,

      Ifayela le-txt lingumbhalo osobala, njengoba negama lisho ... okusobala, ngaphandle kwamafomethi noma okunye okufana nalokho, ngiyaxolisa kepha ngicabanga ukuthi lokhu okucelayo akunakwenziwa, akunjalo? 🙁

      Phendula ngokucaphuna

      1.    i-aca kusho

        empeleni ingakwazi, kepha kuzofanele wazi ifomethi yendawo okuyiwa kuyo.
        isb.
        echo echo (echo "Robert: Sawubona. Shintsha lapha" | sed 's / \ ./. \\ e [40; 31m /; s / \: / \ \ e [40; 35m /')
        kuyindaba yokudlula.
        enye indlela yokususa engasetshenziswa yi- sed '/' $ 1 '/ d' kepha kufanele uqiniseke nge-re.

        1.    LycusHackerEmo kusho

          bese uqeda ukuyigcina ku- * .odt

          Ingabe ayikho indlela elula yokukwenza ngeLibreOffice?

  6.   Lolo kusho

    Ungasusa ingxenye yomugqa bese ushiye okusele?

    Ake sithi ngifuna ukususa yonke into phambi kwegama emgqeni othize.

    Noma susa konke okulandela lelo gama.

    1.    i-aca kusho

      Yebo, kuyindaba yokudonsa i-regex (uma kunesidingo indoda sed -r, –regexp-extended)
      Ukuqala kulokho engikutholayo
      echo «URobert: Sawubona. Shintsha lapha »| sed 's / Shintsha //'
      ngephethini echazwe kahle futhi nge. (uhlamvu olulodwa) no * (ngaphezu kweyodwa)
      Ngemuva:
      echo «URobert: Sawubona. Shintsha lapha »| sed 's / Shintsha. * //'
      Ngaphambi:
      echo «URobert: Sawubona. Shintsha lapha »| sed 's /. * Shintsha //'
      Uma kubalulekile ukuthi igama livele
      echo «URobert: Sawubona. Shintsha lapha »| sed 's / Shintsha. * / Shintsha /'
      noma kabanzi
      kulayini oqukethe uRobert okulandela i-Change
      echo -e «Fritz: Sawubona. Shintsha lapha \ nRobert: Sawubona. Shintsha lapha »| sed '/Robert/s/Cambio.*//'
      noma njengasekuqaleni khipha umugqa wesibili bese ucubungula okusele
      echo -e «Fritz: Sawubona. Shintsha lapha \ nRobert: Sawubona. Shintsha lapha \ nOkunye »| sed -e 2d -e 's / Shintsha. * //'
      echo -e «Fritz: Sawubona. Shintsha lapha \ nRobert: Sawubona. Shintsha lapha \ nOkunye »| sed '2d; s / Shintsha. * //'

      1.    Lolo kusho

        Ngiyabonga, ilusizo kakhulu kimi.

  7.   msx kusho

    I-athikili enhle, engiyithandayo, enhle kangakanani iSysAdmin!
    Impilo yethu ingaba yini ngaphandle kwe-sed, i-awek, i-perl, i-grep, umsila, ikhanda, ama-"Emac" namanye amathuluzi amaningi abalulekile!?

  8.   ULisbeth Ollarves kusho

    Ngiyabonga, kube wusizo olukhulu.

  9.   I-Perni kusho

    Sawubona, futhi ungayisusa kanjani imigqa engu-1,4 no-10 kufayela elikumyalo ofanayo?