commands detail - t

tail

1. gc file.txt | select-object -last 10

tail -f

1. 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:

1. 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:

1. time egrep ORA- *log

….and get all the egrep output, then

1. real    0m4.649s
2. user    0m0.030s
3. sys     0m0.112s

In Powershell, you would do this

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

…and get…

1. Days              : 0
2. Hours             : 0
3. Minutes           : 0
4. Seconds           : 0
5. Milliseconds      : 105
6. Ticks             : 1057357
7. TotalDays         : 1.22379282407407E-06
8. TotalHours        : 2.93710277777778E-05
9. TotalMinutes      : 0.00176226166666667
10. TotalSeconds      : 0.1057357
11. 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

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

I found the set-content command at Super User, the contributor being user techie007

touch - update the modified date

1. set-itemproperty -path c:\temp\new_empty_file.dat -name LastWriteTime -value $(get-date)

I got this from a comment by Manung Han on the Lab49 Blog. Doug Finke shares touch function in a later comment on the same post that fully implements the linux command.