shell cmd transfair windows cmd - linux

I have a regexp using grep which I use to get the latest directory matching it.
Any chance I get a equivalent command as the one below to work on a windows machine?
ls | grep -E "20[0-9]{2}-[0-1][0-9]-[0-3][0-9]-[0-9]{0,5}" | tail -1
I would appreciate any help.

Installing cygwin will give you a nearly linux like shell environment. When you set the cygwin bin into your windows PATH you can even build the pipe like that in a CMD. I can't say anything about the unix like stuff that newer windowses are supposed to bring along though.

Related

Using 'help' for Linux commands on Git for Windows BASH

I installed Git for Windows. The available help in the BASH terminal gives me help only for Git commands.
$ help
$ man and
$ info
DO NOT WORK.
Entering $ help gets me a long list of things, but none of the underlying Linux commands. Here's the entire 'L' section from $ help:
let arg [arg ...]
local [option] name[=value] ...
logout [n]
I'm sure I can look up an online reference of linux commands and keep that open while using BASH. But it would be awfully handy if I could I could type $ man ls and actually get something useful instead of
bash: man: command not found
Anyone know if there's a simple way to sort of add that in to the Git for Windows application? Or if there's another tool that's as easy to use on Windows that has the feature built in? I'm not very tech savvy, but I'm very, very slowly warming up.

Translate Linux 'cut' command to Windows command

I am running some code which necessitates the usage of the following line exactly:
cat data/train.txt | cut -d$'\t' -f 2 | grep -v "^$"| sort | uniq > data/labels.txt
Does Anyone know how this line of command can be translated to a Windows command - or what it means?
P.S. I have been trying to run the code through WSL on my Windows, and the line does execute correctly, however the package I'm trying to use necessitates use of Pytorch with GPU access, which WSL does not facilitate, thus the need to use it on the Windows command line
The Answer was provided by #a_horse_with_no_name, as downloading the utix utilities for windows from: unxutils.sourceforge.net

pwd doesn't work in windows when I include the git bash command line?

I add the bin of git bash into my path in windows7 for the purpose of using linux command in windows. Other commands like ls, mkdir work fine but when I run "pwd" windows can't execute it. I found there is no pwd.exe in the bin directory. So I want to ask where I could download this file or if there is any better way to fix it? Thanks.
in windows de equivalent command for pwd is path. Change pwd with path
A better way of using linux commands on windows is using Cygwin. It will not only allow you to run pwd and other linux commands but it will also make your windows command line as powerful as the linux terminal.
Check out the link below:
https://www.cygwin.com
For Command Prompt in windows which is equivalent of Terminal, you can use cd , instead of pwd... and dir instead of ls.

Linux command to DOS

I have a file include some linux command and I want to run in on windows (DOS command).
The command is:
cat tmp/$id/index.html | sed -e 's/ID/$id/g' > a;mv a tmp/$id/index.html
What is the similar command in MS-DOS?
Thank you!
The problem is that natively there is no equivalent command to sed. You have two options from my point of view. Either create a vb script that does what you want (It will not take 1 line though - more like 10-15 I guess), or use something like GnuWin32 that gives you the option to run unix commands in windows terminal.
You could consider using powershell to do approximately the same thing. It supports cat and mv and you can get a sed like equivalent by using %{_ -replace "expression", "replace"}. Details here http://blogs.msdn.com/b/zainnab/archive/2007/07/09/grep-and-sed-with-powershell.aspx
Or consider using a linux like command prompt like bash which should be available through cygwin
I think this is impossible to do in "bare" command line (as you called DOS command), because cat and sed are separate utilities. If you want to port this script from Linux command shell to windows command line, I would advise you to download and install CygWin
DOS itself does not have support for that. You could try with a port of SED for DOS available here. If you can get Powershell, that's an option. Here's an example of using grep/sed with Powershell.
There are many options.
You can try to install cygwin or download and install Git and use Git-bash or add the bin directory to your PATH so you can run this command on your CMD prompt.
There is no such command(s) for MS-DOS.

built in unix / linux command for recursive find and replace?

Many people string together find and sed, or perl, or any number of other unix commands to find and replace across multiple files. But, there's a simple command that can do it for you without the hassle?
Edit:
The Digital Ninja points out that it's rpl.
However this is not a built in command but, for debian based distros like Ubuntu you can simply install it with
sudo apt-get install rpl
I would guess that it's available through most package managers in other *nix OSs.
OS X Users can download a binary at
http://www.laffeycomputer.com/rpl.html
I belive you are thinking of 'rpl'
http://www.linux.org/apps/AppId_2684.html
I think some variation of the following would work :
find . -name *.extension | perl -pi.bak -e "s/text_to_be_replaced/replacement/"

Resources