SlideShare a Scribd company logo
文字處理及輕量測試

      Jason
字串
 建立字串只需用一對單引號’’或雙引號” “
字串
 利用 backquote
Insert String
Insert String
-like
-like
-replace
Get-Content
  $lines = Get-Content .Test.txt
  $lines.GetType()

  $lines[0]
  $lines[0..4]
Param
 Param($path)

 $lines = Get-Content $path
 $lines.length
 $lines.GetType()




  Test.ps1 .Test.txt
Get-Content String
   Param($Path)

   $lines = Get-Content -Path $Path
   $newLine = [System.Environment]::NewLine

   $content = [String]::Join($newLine,$lines)
   $content
Set-Content
  $files = dir *.txt
  Set-Content -Value $files -Path Test1.txt
Extract-Number
 # .ExtractNumbers.ps1 Test.txt
 Param($path)
 $nums = Get-Content $path
 $numberMatcher = [regex] "d+"

 $matches = $numberMatcher.Matches($nums)
 foreach ($match in $matches)
 {
         if ($match.Success)
         {
                 $number = $match.Groups[0].Value
                 Write-Host "number:$number"
         }
 }
FindStringInFiles
 #.FindString.ps1 "1" C:powerShell *.txt

 Param($query, $path, $filter)

 Set-Location $path

 Select-String $query $filter | select Line,FileName,Path
參考
 http://
 msdn.microsoft.com/zh-tw/magazine/cc163430.aspx

 http://
 technet.microsoft.com/zh-tw/library/dd125489.aspx

More Related Content

PPT
Heap tree
PDF
PPTX
SH 2 - SES 3 - MongoDB Aggregation Framework.pptx
PPTX
Heap sort
DOCX
Rename file folder
PDF
Python - Lecture 4
Heap tree
SH 2 - SES 3 - MongoDB Aggregation Framework.pptx
Heap sort
Rename file folder
Python - Lecture 4

What's hot (20)

PPTX
PPT
Heap sort
PDF
How To Use Higher Order Functions in Scala
PDF
Heap and heapsort
PDF
Data Structure (Static Array)
PPTX
Binary Heap Tree, Data Structure
PPT
Data Structure and Algorithms Heaps and Trees
PDF
Python - Lecture 3
PDF
Apache PIG Relational Operations
PDF
Passing Parameters using File and Command Line
PPT
DOC
Duyet file
PPTX
Python Seaborn Data Visualization
PPTX
Heap Sort in Design and Analysis of algorithms
PPTX
heap Sort Algorithm
PDF
Python programming : List and tuples
PDF
Inheritance & polymorphism java oop
PPT
Array1
PPTX
Heap Sort Algorithm
PPTX
R seminar dplyr package
Heap sort
How To Use Higher Order Functions in Scala
Heap and heapsort
Data Structure (Static Array)
Binary Heap Tree, Data Structure
Data Structure and Algorithms Heaps and Trees
Python - Lecture 3
Apache PIG Relational Operations
Passing Parameters using File and Command Line
Duyet file
Python Seaborn Data Visualization
Heap Sort in Design and Analysis of algorithms
heap Sort Algorithm
Python programming : List and tuples
Inheritance & polymorphism java oop
Array1
Heap Sort Algorithm
R seminar dplyr package
Ad

Viewers also liked (18)

PPTX
20151120 ian cocos2d js
PPT
PPT
Ken - caman.js,SoundManager2.js,CSS3 Animations
PPTX
Auto fac的介紹 20131018
PPTX
Peggy - XPath
PPTX
Auto fac的介紹 20131018
PPT
20121228 jQueryui - dialog - By Drake
PPTX
20130719 Howard_下載檔案的五四三
PPTX
Angular module
PPTX
Design pattern builder 20131115
PPTX
Power shell – scriptblock
PPTX
20150724 jason winston js
PPTX
SignalR
PPTX
Expression 的介紹及應用
PPTX
Kockout
PPTX
Powershell enum
PPTX
mongoose
PPTX
R language
20151120 ian cocos2d js
Ken - caman.js,SoundManager2.js,CSS3 Animations
Auto fac的介紹 20131018
Peggy - XPath
Auto fac的介紹 20131018
20121228 jQueryui - dialog - By Drake
20130719 Howard_下載檔案的五四三
Angular module
Design pattern builder 20131115
Power shell – scriptblock
20150724 jason winston js
SignalR
Expression 的介紹及應用
Kockout
Powershell enum
mongoose
R language
Ad

More from LearningTech (20)

PPTX
PPTX
PostCss
PPTX
ReactJs
PPTX
Docker
PPTX
Semantic ui
PPTX
node.js errors
PPTX
Process control nodejs
PPTX
Expression tree
PPTX
SQL 效能調校
PPTX
flexbox report
PPTX
Vic weekly learning_20160504
PPTX
Reflection & activator
PPTX
Peggy markdown
PPTX
Node child process
PPTX
20160415ken.lee
PPTX
Peggy elasticsearch應用
PPTX
Expression tree
PPTX
Vic weekly learning_20160325
PPTX
D3js learning tips
PPTX
git command
PostCss
ReactJs
Docker
Semantic ui
node.js errors
Process control nodejs
Expression tree
SQL 效能調校
flexbox report
Vic weekly learning_20160504
Reflection & activator
Peggy markdown
Node child process
20160415ken.lee
Peggy elasticsearch應用
Expression tree
Vic weekly learning_20160325
D3js learning tips
git command

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
A Presentation on Artificial Intelligence
PPTX
Tartificialntelligence_presentation.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Approach and Philosophy of On baking technology
PDF
August Patch Tuesday
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Encapsulation_ Review paper, used for researhc scholars
TLE Review Electricity (Electricity).pptx
Web App vs Mobile App What Should You Build First.pdf
cloud_computing_Infrastucture_as_cloud_p
A Presentation on Artificial Intelligence
Tartificialntelligence_presentation.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Enhancing emotion recognition model for a student engagement use case through...
Approach and Philosophy of On baking technology
August Patch Tuesday
A comparative study of natural language inference in Swahili using monolingua...
1. Introduction to Computer Programming.pptx
Programs and apps: productivity, graphics, security and other tools
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Hindi spoken digit analysis for native and non-native speakers
Chapter 5: Probability Theory and Statistics
A comparative analysis of optical character recognition models for extracting...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf

20120518 power shell_文字處理及輕量測試