Can't use grep for Windows? - cmd

I am running Windows 10 on this laptop and recently was recommend to install grep. Well I did that by installing it with a program called GNUWin32.
For some reason I can't get grep to work. Maybe I'm stupid? I don't know but when I type the grep command in CMD it doesn't recognize it.
Any ideas?

Related

How to write the xxd command in cmd in windows

I am trying to use xxd command to convert string to hex.
I have typed this command in cmd in windows xxd -p <<< "Hello world".
But I have got this in my cmd
'xxd' is not recognized as an internal or external command, operable program or batch file.
How can I use xxd in cmd in windows?
Thanks.
Use VIM for this
https://ftp.nluug.nl/pub/vim/pc/gvim73_46_s.zip
C:\Program Files (x86)\Vim\vim74>.\xxd -v
Source: https://superuser.com/a/638850
You could use git-bash to do that if you have installed it.
Short answer is you probably can't because it's a UNIX command...
What you can do is use GnuWin32/MinGW/CygWin, which are ports of Linux GNU utilities fro Windows.
Read more about them here:
Difference between GNUWin32 and cygwin
These days the full linux kernel is made available and officially supported by windows via WSL. Once installed, a program like Windows Terminal can be used to execute linux commands.
See this utility clone.
https://sourceforge.net/projects/xxd-for-windows/
The operation is similar. To see in hexadecimnal use "xxd file.txt", to see in binary use "xxd -b file.txt".

jq crashing under Windows 10 using any command

I've used jq on Mac/Unix successfully for several years and have now been asked to port a project from Mac to Windows.
My problem is that I am unable to run any command in jq under Windows with the .json files that work perfectly on the Mac.
This includes the simplest command:
jq -r . /path/to/json.json
All commands cause a crash of jq. I'm running Windows 10 Pro.
What I've tried:
-Installing jq using chocolatey as well as downloading the precompiled 32-bit and 64-bit binaries directly.
-Using a standard command prompt, an elevated command prompt and PowerShell.
The .json files all have UTF-8 encoding without BOM and I've tried them with both Windows and Unix line endings. jq crashes regardless.
Can anyone please provide any guidance as to why a simple port to Windows would be so problematic, or maybe some simple issue I am overlooking?
Thanks
This includes the simplest command:
jq -r . /path/to/json.json
To ascertain the nature of the problem, it would probably be better to start with an even simpler command, such as:
jq -n .
If that fails, maybe there is a 32-bit/64-bit mismatch.
Also, when specifying pathnames, you will have to use Windows conventions.
Please note that jq 1.5 cannot handle long Windows pathnames. You can obtain a more recent version of jq pre-compiled for Windows from Appveyor, as explained at
https://github.com/stedolan/jq/wiki/Installation#windows-using-appveyor

Is there an equivalent of tail -f on Windows?

Many times I find myself in the situation of having to follow the evolution of a log file on Windows. Is there an equivalent of the Linux
tail -f <filename>
command on a Windows terminal, preferably without having to install external software? Other SO posts talk about installing third-party programs.
In Powershell you can use Get-Content with the -Wait flag:
Get-Content filename.log -Wait
You can shorten Get-Content to gc. That question suggested as a possible duplicate has an answer which mentions this and some useful extra parameters -
see https://stackoverflow.com/a/188126. I'm not sure if it's really a duplicate, though, since that question is talking about general Windows alternatives to Linux tail, rather than about tail -f.
In Powershell use:
cat .\<file_name> -Tail 10 -Wait
Yes. you can use tail on windows, which is a small price to pay to get access to a lot of GNU-tools on windows as well as tail. Because its bundle with git for windows, its pretty heavily tested and stable.
First install git-bash from https://gitforwindows.org/
Next, put git-bash on windows path using and reboot your workstation:
setx path "%path%;C:\Program Files\Git\bin\"
Now, you should be able to use tail -n 20 -F logging_file.log to tail any file and show the last 20 lines.
If you are on Linux/Unix and you want to continuously see logs you can use the following command:
ssh username#10.15.3.3 'bash -c "tail -n 20 -F /c/Users/username/Desktop/logging_file.log"'
I know you said without external program. But for the people who have already installed the Windows Subsystem for Linux (WSL) and they cannot make tail work properly in Ubuntu 16.04 LTS I found this thread where somebody found a workaround:
In case anyone finds this through Google, it seems that inotify support in WSL is limited to WSL file accesses, not win32 file accesses, so you have to tell tail not to use it:
tail -f /mnt/c/path/to/file ---disable-inotify
(yes, three dashes)
Get-Content filename -Wait -tail 1
this worked for me, as said by nikobelia, just added the tail option and it works as expected!

How can I make a Perl script executable in Windows 64bit?

I am trying to run the perl script through command line but it is not reorganizing the script file ie.
myscript.pl... is not working
but perl myscript.pl is working fine
I have tried the following suggestions but they didn't work either
How do I make my Perl scripts act like normal programs on Windows?
Perl execution from command line question
I am using Active Perl:- Perl 5 , Version 18.
It gives following warnings in both cases.
Using a hash as a reference is deprecated
earlier I installed strawberry perl before installing active perl, is that causing some problem.
The error message
Using a hash as a reference is deprecated
is a Perl message. Your script is being run just fine, but contains an error.
(It is remotely possible that you have two Perl versions installed, and that you configured Windows to use the wrong one. Reconfigure it to use the correct on then, using the guides you already found.)

how to run bash file in win-bash

I am unfortunately having to use windows in work, and so I have installed win-bash to have a unix shell running. all going well but I am having an issue running the following .sh file:
bash $ ./qf.sh
.\qf.sh: option not available on this NT BASH release
.\qf.sh: fork: Bad file descriptor
qf.sh is:
#!/bin/bash
cat test.csv | while read line
do
echo "${line//,/ }" | xargs ./adder
done
I find it hard to believe someone would create a bash emulator incapable of running a bash file. curious that the error message writes .\qf as opposed to ./qf
Can anyone shed some light on this?
use MinGW or Cygwin
MinGW: http://sourceforge.net/projects/mingw/files/?source=navbar
Cygwin: http://www.cygwin.com/
Using Cygwin absolutely killed this error for me. I do wonder however, how this should work with MinGW. I don't see any unix command executable directory to include in the path (like cygwin64\bin with Cygwin)

Resources