One liners: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== sed == Replace all enters with spaces with sed. <pre> sed ':a;N;$!ba;s/\n/ /g' </pre> <br> Replace all uppercase letters with lowercase with sed. <pre> sed -e 's/\(.*\)/\L...") |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 16: | Line 16: | ||
</pre> | </pre> | ||
Get only the dashed mac addresses from a file | |||
<pre> | |||
grep -o '..-..-..-..-..-..' file | |||
</pre> | |||
== Powershell == | == Powershell == | ||
Line 22: | Line 26: | ||
<pre> | <pre> | ||
C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -command "& {$app = Get-WmiObject -Class Win32_Product -Filter \"Name = 'Linphone'\"; $app.Uninstall() }" | C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -command "& {$app = Get-WmiObject -Class Win32_Product -Filter \"Name = 'Linphone'\"; $app.Uninstall() }" | ||
</pre> | |||
Actually a two liner, but this is to put your computer to sleep after 60 seconds from the commandline. Note: hibernate should be turned off for this. | |||
<pre> | |||
timeout 60 | |||
rundll32.exe powrprof.dll,SetSuspendState 0,1,0 | |||
</pre> | |||
Remove all files in the current directory older than 30 days. | |||
<pre> | |||
forfiles /D -30 /C "cmd /C attrib -s @file & echo @file & del @file" | |||
</pre> | |||
Clear all Windows Event Viewer logs. | |||
<pre> | |||
wevtutil el | Foreach-Object {wevtutil cl “$_”} | |||
</pre> | </pre> |
Latest revision as of 19:09, 3 January 2020
sed
Replace all enters with spaces with sed.
sed ':a;N;$!ba;s/\n/ /g'
Replace all uppercase letters with lowercase with sed.
sed -e 's/\(.*\)/\L\1/'
The same with tr
tr '[:upper:]' '[:lower:]'
Get only the dashed mac addresses from a file
grep -o '..-..-..-..-..-..' file
Powershell
One liner powershell command to uninstall the application 'Linphone'.
C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -command "& {$app = Get-WmiObject -Class Win32_Product -Filter \"Name = 'Linphone'\"; $app.Uninstall() }"
Actually a two liner, but this is to put your computer to sleep after 60 seconds from the commandline. Note: hibernate should be turned off for this.
timeout 60 rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Remove all files in the current directory older than 30 days.
forfiles /D -30 /C "cmd /C attrib -s @file & echo @file & del @file"
Clear all Windows Event Viewer logs.
wevtutil el | Foreach-Object {wevtutil cl “$_”}