Hot answers tagged

8

Save this to a file, let's say patterns.awk, then call awk -f patterns.awk patterns data, where patterns is your first file, and data the second: NR == FNR { prefix[NR] = $0; pattern[NR] = $2; count++; next; } { for (i = 1; i <= count; i++) { if (index($1, pattern[i]) > 0) { print prefix[i] " " $0; ...


6

You installed cygwin, so you can just use its shell for maximum command support : "C:\Program Files\Cygwin\cygwin.bat this will give you a bash shell Then you can change directoty to go to the images location. Suppose your image location is "D:\Your Name\Images", to go there type cd "/cygdrive/d/Your Name/Images" and then call your command using the bash ...


5

Poking around with various inputs, I felt grep did its own magic for line-endings: $ printf "foo\rbar\n" | grep -oz $'\r' | od -c 0000000 \r \n 0000002 $ printf "foo\rbar\r\n" | grep -oz $'\r' | od -c 0000000 $ printf "foo\rbar\r" | grep -oz $'\r' | od -c 0000000 \r \n \r \n 0000004 (The -z was my lame attempt to make grep match everything.) And so ...


5

I just ran into this problem connecting to a headless RHEL7 server. You need the xorg-x11-xauth package installed on your host in order for the DISPLAY variable to get set, and to be properly authorized. Hope I saved somebody some time.


4

Input files: yahoo.net.txt gougle.com.txt reddit.com.txt Contents of yahoo.net.txt: user1-yaho0 pas,, Contents of gougle.com.txt: user1-google pas"wor,d Contents of reddit.com.txt: user1-reddit pas\wor\d With this input, the following quick and dirty script does the job: #!/bin/bash echo "\"Account\",\"Login Name\",\"Password\",\"Web Site\",\"...


4

There are at least 2 mechanisms readily available in Linux (but probably not in cygwin). There is the fuse filesystem, see man fuse, which allows you to implement a filesystem in user-space. For example, curlftpfs (see its man page) converts file accesses into curl ftp calls. Then there is the fanotify system call, which allows you to intercept calls made ...


3

This is a locale issue, compare the output of locale in your two environments, and adjust the one where you want the output changed. For example, on Linux (the sort version or OS shouldn't matter much): $ LC_ALL=C sort t -------- ----------- -=-=-=-=-=- =========== $ LC_ALL=en_US.UTF-8 sort t =========== -=-=-=-=-=- -------- -----------


3

Reviving an old threat, however I stumbled across this while doing my own search. So rather than make a new thread - Here's what I found: http://babun.github.io/ The core of Babun consists of a pre-configured Cygwin. Cygwin is a great tool, but there’s a lot of quirks and tricks that makes you lose a lot of time to make it actually 'usable'. Not ...


2

To my great surprise, picocom worked out of the box for what i needed to do - talk to embedded devices. There is no cygwin package for some reason, but building it is as easy as git clone https://github.com/npat-efault/picocom; cd picocom && make Assuming your device shows as COM3 under windows, run with ./picocom -b 115200 /dev/ttyS2


2

Simple if the keyword is always in the same column, e.g. column number 2 cut -d, -f 2 file(s) | grep -c 'true' i.e. cut out column 2 (-f 2), using "," as field seperator ( -d, ), get (grep) all trues and count them (-c) more complicated, if we have to search for column "ARD" awk 'BEGIN {FS = ","} ; FNR == 1 { for ( i=1 ; i<=NF ; i++ ) { if ( $i=="...


2

Literally 5 seconds after I've posted the question, I found the answer. The rpmbuild command is incorrect; if I execute rpmbuild --nodeps --target=i386-linux --buildroot="$BUILDDIR" -bb $ROOTPATH/tmp.spec everything works correctly and I can install the resulting RPM on Linux.


2

Try: n=0; for f in *.jpg; do mv "$f" "$((++n)).jpeg.jpg"; done Or, the same thing spread out over multiple lines: n=0 for f in *.jpg do mv "$f" "$((++n)).jpeg.jpg" done How it works n=0 This initializes the variable nn. for f in *.jpg; do This starts a loop over all files in the current directory whose names end with .jpg. mv "$f" "$((++n))....


2

Consider this more of an expansion/enhancement to @Slyx's answer. Cygwin has a useful utility cygpath to convert Windows path to *nix-style understood within Cygwin's bash shell: $ cygpath "D:\Path\To\Images" /cygdrive/d/Path/To/Images Instead of the explicit for-loop suggested, you can also consider using find that has better support for filtering ...


2

This is nothing to do with Unix or Linux. It's entirely Win32 and Cygwin. As first discussed in the Microsoft doco for Win32 and various Win32 programmers guides almost a quarter of a century ago, the Windows NT kernel doesn't have a notion of multiple drives each with their own individual working directories. This MS-DOS paradigm is emulated in Win32 ...


2

Hi I'm one of the rmlint dev's. Unfortunately I don't think you'll be able to get rmlint running under cygwin (although happy to be proven wrong). Edit: have been proven wrong. Now have more-or-less working command-line version of rmlint under cygwin. It requires: gcc-core pkg-config libglib2.0-devel libtool and optionally: libjson-glib 1.0-devel ...


2

I got PDFtk commands with Cygwin by installing the server version of PDFtk (https://www.pdflabs.com/tools/pdftk-server/) in Windows 7 64bits. While installing PDFtk Server, make sure to check the box saying to apply PDFtk to the system environment. Once the installation is done, type "pdftk" in Cygwin and it should give the expected results.


2

Restore the files from backup. If you don't have a backup, the files were important and you are lucky, you might try extundelete tool. Possibly use another machine to install it and mount the disk as external. To protect yourself from such mistakes in future: make backups, test before you run, and add following to your bash profile: alias cp='cp -i' ...


2

On my cygwin environment the docker cert path is actually set as below and docker seems to work fine. DOCKER_CERT_PATH=C:\Users\user\.docker\machine\machines\default The following does indeed give an error DOCKER_CERT_PATH=/cygdrive/c/Users/user/.docker/machine/machines/default $ docker version Could not read CA certificate "\\cygdrive\\c\\Users\\user\\....


2

grep -rlZ --exclude-dir=dir1 --exclude-dir=dir2 HUMAN . | xargs -r0 rm -f If you want find to do the directory traversal: find . -type d \( -name dir1 -o -name dir2 \) -prune -o \ -type f -exec grep -lZ HUMAN {} + | xargs -r0 rm -f Portably/standardly, that would have to be: find . -type d \( -name dir1 -o -name dir2 \) -prune -o \ -type f -...


2

There's watch, loops with sleep, crontab, and many other options: watch -n 60 echo hello world while :; do echo hello world; sleep 60; done crontab -e #...


1

It's only in the 32bit version of Cygwin at present, so I assume you're installing and running the 64bit one. Not everything has been ported to the 64bit builds. As you can see from this package search, the nfs-server package is present in the x86 build, but from this search, not in the x86_64.


1

If extundelete doesn't do it for you, the Sleuth Kit has a few tools that might help. fls can give you info about the deleted files in a directory. Testdisk is sometimes helpful, too. Sometimes. Also, it probably goes without saying, but do not write to the drive after you lose a file! The data is still there but the space becomes marked as unallocated ...


1

Replace ; with + at the end. From the manpage: -execdir command {} + Like -exec, but the specified command is run from the subdirectory containing the matched file, which is not normally the directory in which you started find. This a much more secure method for invoking commands, as it avoids race ...


1

There is search on cygwin website (and also google). If you try the same search with x86_64 architecture, there is no such package. This question was asked many times and answered also. Just use 32 bit version, if you want all the packages.


1

One option is to pass the shell variable into awk, which avoids requoting: awk 'NR>13 {if ($4==dmn) print $1, $2, $3, $4;}' dmn="${DMN[$i]}" domain_all.dat >> ddh_domain_${DMN[$i]}.dat I'd be inclined to refactor your shell script, too, so that the variable is passed into your shell function: declare -a DMN=(" " "200" "190" "180") NRL=3 ...


1

Since the number of files can be "unlimited", there is a builtin limit to the size of the command line. See http://stackoverflow.com/questions/19354870/bash-command-line-and-input-limit . Therefore, I would use find to solve this. E.g, in bash: cd /path/to/directory n=1 find . -maxdepth 1 -type f -name "*.jpeg.jpg" | sort | while read file; do mv "$...


1

j=0; for i in `ls` do mv $i $j.jpeg.jpg j=`echo $j + 1 | bc` done


1

Upgrading cyg-get solved the problem.


1

Unix GUI programs display through an X server. Cygwin doesn't automatically start an X server. You need to install the packages xorg-server and xinit, and run startxwin.


1

By default, the 'top' command will display Cygwin processes by CPU usage. If you'd like to view only Windows processes, you can use the 'ps' command, and then sort your results by CPU usage: ps -W | sort -nk 3 where: -W refers to Windows processes, -n refers to a numerical sort, and -k refers to a key, in this case the 3rd column ...



Only top voted, non community-wiki answers of a minimum length are eligible