Hello,
I am new to batch scripting and have hit something of a show stopper for me.
I am trying to automate the capture of data from our Cisco switches and managed to get a batch script working with plink earlier today.
Very exciting stuff.
Now that I have the output saved in a file (say rawMACList.txt), I am trying to pull out only the parts of the file that I need.
I have identified these lines as being the only ones that begin with a digit, so that seems like it will be straight forward enough.
But, I am having trouble searching through the entire file. Looking at the file in Notepad++, I see a NUL character right up near the top (about 15 lines in) and all processing by my For loop stops at that point.
How can I go about removing or replacing this NUL, within my script, prior to the main processing For loop?
Oh! On this computer, I am extremely locked down, so sed and every other easy solution that requires an additional download is right out. The only reason I was able to even get plink.exe is because of puTTY.
Thanks. If you need any additional details, I will do my best to provide them.
Remove/Replace NUL in file
Moderator: DosItHelp
Re: Remove/Replace NUL in file
Try this, but your file could be unicode or anything else.
Code: Select all
findstr ^[0-9] "yourfile.txt" > "newfile.txt"
-
- Posts: 4
- Joined: 15 Jul 2016 13:28
Re: Remove/Replace NUL in file
I didn't really understand that at first, but it struck me this morning what you were accomplishing.
I just ran it on the file and it worked amazingly well.
Thank you! Profoundly.
I just ran it on the file and it worked amazingly well.
Thank you! Profoundly.
Re: Remove/Replace NUL in file
High_Noonan wrote:Thank you! Profoundly.
Nice to hear it works, ta.
Code: Select all
findstr ^[0-9]
This is a regular expression ^[0-9]
The ^ means to anchor the text to the start of a line, so anything in the following parts of the regular expression only triggers when it is at the very start of a line.
This means to search for any character that is within the range of zero to nine - which is all numerals obviously.
[0-9]
Check out this post viewtopic.php?p=47920#p47920
