A Unix Person's Guide to PowerShell
  • ReadMe
  • About this Book
  • Introduction to PowerShell for Unix People
  • Commands Summary
  • Command Detail - A
  • Command Detail - B
  • Command Detail - C
  • Command Detail - D
  • Command Detail - E
  • Command Detail - F
  • Command Detail - G
  • Command Detail - H
  • Command Detail - I
  • Command Detail - J
  • Command Detail - K
  • Command Detail - L
  • Command Detail - M
  • Command Detail - N
  • Command Detail - O
  • Command Detail - P
  • Command Detail - Q
  • Command Detail - R
  • Command Detail - S
  • Command Detail - T
  • Command Detail - U
  • Command Detail - V
  • Command Detail - W
  • Command Detail - X
  • Command Detail - Y
  • Command Detail - Z
  • Command Detail - Non-alphabetical
  • To-do
Powered by GitBook
On this page
  • tail
  • tail -f
  • tee
  • time
  • touch - create an empty file
  • touch - update the modified date

Command Detail - T

tail

gc file.txt | select-object -last 10

gc is an alias for get-command

tail -f

gc -tail 10 -wait c:\windows\windowsupdate.log

tee

The Powershell equivalent of the unix tee is tee-object....which, by default is aliased to tee

So you can do this:

get-process | tee c:\temp\test_tee.txt

...to both get a list of processes on your screen and get that output saved into the file in c:\temp

time

The Powershell equivalent of the bash shell 'time' is 'measure-command'.

So, in bash you would do this:

time egrep ORA- *log

....and get all the egrep output, then

real    0m4.649s
user    0m0.030s
sys     0m0.112s

In Powershell, you would do this

measure-command {select-string ORA- *.sql}

...and get...

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 105
Ticks             : 1057357
TotalDays         : 1.22379282407407E-06
TotalHours        : 2.93710277777778E-05
TotalMinutes      : 0.00176226166666667
TotalSeconds      : 0.1057357
TotalMilliseconds : 105.7357

...you don't get the 'user CPU' time and 'system CPU' time, but you do get the added bonus of seeing how long the command took rendered as a fraction of a day!

touch - create an empty file

set-content -Path c:\temp\new_empty_file.dat -Value $null

touch - update the modified date

set-itemproperty -path c:\temp\new_empty_file.dat -name LastWriteTime -value $(get-date)
PreviousCommand Detail - SNextCommand Detail - U

Last updated 7 years ago

I found the set-content command at , the contributor being

I got this from a comment by on the . Doug Finke shares in a later comment on the same post that fully implements the linux command.

Super User
user techie007
Manung Han
Lab49 Blog
touch function