Yuav ua li cas rau Redirect Command Prompt Output rau cov ntaub ntawv

Cov txheej txheem:

Yuav ua li cas rau Redirect Command Prompt Output rau cov ntaub ntawv
Yuav ua li cas rau Redirect Command Prompt Output rau cov ntaub ntawv
Anonim

Yuav Paub

  • The > tus neeg teb xov tooj hloov mus ntawm ipconfig cov lus txib thiab lub npe cov ntaub ntawv.
  • Yog cov ntaub ntawv twb muaj lawm, nws yuav raug sau dua. Yog tsis yog nws yuav tsim.
  • The >> tus neeg teb xov tooj ntxiv cov ntaub ntawv. Es tsis txhob overwriting cov ntaub ntawv tso zis, nws ntxiv cov lus txib tso tawm mus rau qhov kawg ntawm cov ntaub ntawv.

Siv tus neeg teb xov tooj rov qab los hloov cov lus tso tawm ntawm cov lus txib mus rau cov ntaub ntawv. Tag nrho cov ntaub ntawv uas tau tshwm sim hauv Command Prompt tom qab khiav ib qho lus txib tuaj yeem khaws cia rau hauv cov ntaub ntawv, uas koj tuaj yeem qhib hauv Windows los siv tom qab lossis tswj qhov koj nyiam.

Yuav siv cov neeg ua haujlwm hloov pauv li cas

Thaum muaj ntau tus neeg tsav tsheb hloov pauv, ob, tshwj xeeb, yog siv los tso cov txiaj ntsig ntawm cov lus txib rau cov ntaub ntawv: ntau dua-siv npe (>) thiab ob npaug ntau dua kos npe (>>).

Txoj hauv kev yooj yim tshaj plaws los kawm paub siv cov kev hloov pauv no yog saib qee qhov piv txwv:


ipconfig /all > mynetworksettings.txt

Image
Image

Hauv qhov piv txwv no, tag nrho cov ntaub ntawv teeb tsa lub network, ib txwm pom ntawm lub vijtsam tom qab khiav ipconfig /all, tau khaws cia rau hauv cov ntaub ntawv los ntawm lub npe ntawm mynetworksettings.txt. Nws tau muab cia rau hauv daim nplaub tshev rau sab laug ntawm cov lus txib, C:\Users\Jon hauv qhov no.

The > tus neeg teb xov tooj hloov mus ntawm ipconfig hais kom ua thiab lub npe ntawm cov ntaub ntawv. Yog hais tias cov ntaub ntawv twb muaj lawm, nws yuav overwritten. Yog tsis muaj lawm ces yuav tsim.

Txawm tias cov ntaub ntawv yuav raug tsim yog tias tsis muaj lawm, folders yuav tsis. Txhawm rau txuag cov lus txib tso tawm rau cov ntaub ntawv hauv ib lub nplaub tshev tshwj xeeb uas tseem tsis tau muaj, ua ntej, tsim cov ntawv tais ceev tseg thiab tom qab ntawd khiav cov lus txib. Ua folders yam tsis tau tawm hauv Command Prompt nrog mkdir hais kom ua.


ping 10.1.0.12 > "C:\Users\Jon\Desktop\Ping Results.txt"

Image
Image

Ntawm no, thaum ping hais kom ua tiav, Command Prompt tso tawm cov txiaj ntsig rau cov ntaub ntawv los ntawm lub npe ntawm Ping Results.txt nyob ntawm Jon tus neeg siv lub desktop, ntawmC:\Users\Jon\Desktop . Tag nrho cov ntaub ntawv txoj hauv kev qhwv hauv cov lus qhia vim tias muaj qhov chaw koom nrog.

Nco ntsoov, thaum siv tus > tus neeg teb xov tooj rov qab, cov ntaub ntawv teev tseg yog tsim yog tias nws tsis tau muaj thiab tau sau dua yog tias nws muaj.

Tus Neeg Ua Haujlwm Rov Qab Rov Qab Rov Qab

Tus neeg teb xov tooj ob npaug ntxiv, tsis yog hloov, ib cov ntaub ntawv:


ipconfig /all >> \\server\files\officenetsettings.log

Qhov piv txwv no siv tus >> tus neeg tsav tsheb hloov pauv uas ua haujlwm ntau yam zoo ib yam li > tus neeg teb xov tooj, tsuas yog tsis sau cov ntawv tso tawm. cov ntaub ntawv yog tias nws muaj, nws ntxiv cov lus txib tso tawm mus rau qhov kawg ntawm cov ntaub ntawv.

Nov yog ib qho piv txwv ntawm cov ntaub ntawv LOG no yuav zoo li cas tom qab cov lus txib tau raug xa tawm mus rau nws:

Image
Image

The >> tus neeg tsav tsheb rov qab muaj txiaj ntsig thaum koj khaws cov ntaub ntawv zoo sib xws los ntawm cov khoos phis tawj sib txawv lossis cov lus txib thiab koj xav tau tag nrho cov ntaub ntawv ntawd hauv ib cov ntaub ntawv.

Cov piv txwv ntawm tus neeg teb xov tooj hloov pauv saum toj no yog nyob rau hauv cov ntsiab lus ntawm Command Prompt, tab sis koj tuaj yeem siv lawv hauv BAT cov ntaub ntawv. Thaum koj siv cov ntaub ntawv BAT los xa cov lus txib tawm mus rau cov ntawv nyeem, cov lus txib tib yam uas tau piav qhia saum toj no yog siv, tab sis tsis txhob nias Enter kom khiav lawv, koj tsuas yog yuav tsum qhib lub. BAT file.

Siv Redirection Operators hauv Batch Files

Redirection cov tswv ua haujlwm hauv cov ntaub ntawv batch los ntawm kev suav nrog cov lus txib ib yam li koj xav tau los ntawm Command Prompt:


tracert yahoo.com > C:\yahootracert.txt

Image
Image

Cov saum toj no yog ib qho piv txwv ntawm yuav ua li cas ua cov ntaub ntawv batch uas siv tus neeg teb xov tooj rov qab nrog cov lus txib tracert.

Image
Image

Cov ntaub ntawv yahootracert.txt (pom saum toj no) yuav raug tsim rau ntawm C: tsav ob peb feeb tom qab ua tiav cov ntaub ntawv sample.bat. Ib yam li lwm cov piv txwv saum toj no, cov ntaub ntawv qhia txhua yam hais kom ua tiav yuav tau qhia yog tias tus neeg tsav tsheb hloov pauv tsis siv.

Pom zoo: