I have the following Unix shell script. I would like to convert this into a Windows .bat
file (I know I can use Cygwin instead of adapting it to a Windows environment. But Cygwin is not an option for me).
I know I can use Windows PowerShell reading material online. But I don't want to spend hours online learning from basics for this one time requirement. Please don't bash me for being lazy. I am sure this helps others as well by being a quick guide for someone searching online in the future.
Here is the script:
#!/bin/bash
echo ""
cat $1 | grep -A4 "Device_name"; echo ""
cat $1 | grep -A45 "Device_Oops"; echo ""
cat $1 | grep -A150 "Processes:" | sed '/Radar/q'; echo ""
cat $1 | grep -E '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]' | grep -i -E 'error|restart'
To answer questions on what I tried, I have trouble running the "find
" command which is the equivalent of grep
per this website http://tldp.org/LDP/abs/html/dosbatch.html
Here is my Joy.txt
file (next two lines):
Device_name router@home
testing only
Then at the PowerShell prompt I ran the following command:
cat Joy.txt | find "Device_name"
I was expecting to see the first line in the above file. But instead I get the parameter format not correct error. Can someone help please?
See Question&Answers more detail:os