Tag Info

Hot answers tagged

7

You should not use ls to parse files this way. First set extglob globstar by shopt -s extglob globstar then for f in !(*.bat) do printf '%s\n' "$f" done Using find find . -type f ! -name '*.bat' Use the negation operator for a safer treat of files.


5

A few things wrong in your code: Using unquoted command substitution ($(...)) without setting $IFS Leaving expansions unquoted is the split+glob operator. The default is to split on space, tab and newline. Here, you only want to split on newline, so you need to set IFS to that as otherwise that means that will not work properly if filenames contain space ...


5

In the unix world, a newline is a line terminator, not a line separator. A text file consists of a series of lines, each of which is terminated by a newline character. This is a linefeed character (character number 10, which can be represented as LF, ^J, \012, \x0a, \n, …). See What's the point in adding a new line to the end of a file? In particular, ...


4

The /proc file system will list exactly this information: $ ls -l /proc/self/fd total 0 lrwx------ 1 michas users 1 Apr 6 04:44 0 -> /dev/pts/0 lrwx------ 1 michas users 1 Apr 6 04:44 1 -> /dev/pts/0 lrwx------ 1 michas users 1 Apr 6 04:44 2 -> /dev/pts/0 lr-x------ 1 michas users 1 Apr 6 04:44 3 -> /proc/6934/fd $ ls -l /proc/self/fd ...


4

To quit less, type q. Also, check out man less for some more, useful bits of information. In general, assuming man has been properly installed, man xyz will tell you how to use the xyz tool. man will normally display through less as well, so to exit from man, again you would type q.


4

Some of that output will be buffered. You send your Ctrl+C to the remote end which interrupts the running program. The program exists and the shell send the characters to show you the prompt again. Before the prompt is shown your screen will first show all the data that was buffered and already on it's way to you. What you're asking is for the program to ...


3

I don't have access to a cygwin system so I can't test this, but since you want to use Perl regexes, why not use Perl? perl -ne 'print "$_\n" for /.+?\.jpg/g;' file.txt or awk '{for(i=1;i<=NF;i++){if($(i)~/.+?\.jpg/){print $(i)}}}' file.txt However, I suspect that you want to match the shortest string of non-whitespace characters that end in .jpg ...


3

I usually run the output into less so that I can kill it via less instead using the q key. $ cmd | less Example $ cat /dev/urandom | less     After hitting q+Enter it'll quit and return back to your normal terminal, leaving it nice and clean. Why does that happen? The problem you're encountering is that there are buffers (for STDOUT) ...


3

Make sure that you have the DISPLAY-variable set in your cygwin-environment: export DISPLAY=:0.0 after connecting with SSH, check if that shell also knows the correct DISPLAY-variable with: echo $DISPLAY


2

Note: I asked the OP to update his question with output to locale It sounds like you have a locale issue, you can see what your present locale settings are with locale. You most likely have a LC_* setting that is causing make to output in a format that your terminal is not recognizing. If you have chosen a UTF8 charset, and then have a terminal that is not ...


2

rm is part of coreutils. So re-install that. Cygwin doesn't have a fully-featured package manager, but you should be able to rerun setup*.exe (i.e. the original installer - it remembers your packages) to re-select coreutils.


2

There are two things wrong: You cannot use spaces around the assignment operator. As your script currently is, bash interprets the line to mean "run name with the arguments = and Elvin John Paul". The line should look like the following: name="Elvin John Paul" You have Windows-style line endings (CRLF instead of just LF), which results in the error ...


2

Echo is putting newlines between words because it's splitting the input at the spaces, not at the newline. This is also why the eval doesn't work - it sees the first word, containing a ', and doesn't see the end of the line, which contains the closing ' Solution: Change the value of IFS (Internal Field Separator) to not contain spaces or tabs, but just ...


2

I believe screen will do this, cygwin maps COM ports to /dev/stty* devices and screen will take a device to connect. From man screen If a tty (character special device) name (e.g. "/dev/ttya") is spec‐ ified as the first parameter, then the window is directly connected to this device. This window type is similar to "screen cu -l ...


2

A Stack Overflow comment discusses the possibility of this being due to having a version of gcc or make that isn't dealing with the unix/Windows path style conflict. A similar problem was had in another situation, which was resolved by ensuring that Cygwin's version of gcc was installed as it was otherwise falling back on something else. If you do not have ...


2

watch is in procps, so install 'procps' package.


2

There are several levels of buffering. When you press Ctrl+C, this stops the program from emitting data to the terminal. This doesn't affect data that the terminal emulator hasn't displayed yet. When you're displaying data at very high speed, the terminal can't keep up and will lag. That's what's going on here: displaying text is at lot more expensive than ...


1

I would attempt to download the script first and then run it through bash. Example $ curl -v https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash -O % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 ...


1

Having done some research on terminal emulators today, I feel the need to hail the virtues of xterm. This FAQ documents a lot of the bugs in other terminal emulators which aim to be xterm or VT-100 compatible. You can also use vttest to reveal a lot these issues for yourself. What puts a lot of people off of xterm though is the lack of a menu configuration. ...


1

Tip: run set -x to enable tracing mode. Bash prints each command before executing it. Run set +x to turn off tracing mode. + find . '\(' '\)' -exec grep -IH needle '{}' '\;' Notice how the last argument to find is \; instead of ;. You have the same problem with the opening and closing parentheses. In your source, you've quoted the semicolon twice. ...


1

Running bash command using arrays Let try: find /tmp \( -type f -o -type d \) -ls Wow, there is a lot of output... Well, now: cmd_list=(find /tmp \() cmd_list+=(-type f) cmd_list+=(-o -type d) cmd_list+=(\) -ls) "${cmd_list[@]}" Hmm... There seem identical! find /tmp \( -type f -o -type d \) -ls 2>/dev/null | md5sum ...


1

man ssh -L [bind_address:] port:host:hostport Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the ...


1

echo -n '' > /path/to/the/file should replace the file with a 0-byte successor. However, Windows file locking is nearly always a pain only when you don't want it to be. If the program is maintaining an open file handle rather than a series of open-append-close events, this may not work.


1

Don't use for loops for this. By default, as explained by @JennyD, your shell will split on whitespace and not keep the entire line. This is not the case if you read the file into a while loop instead of cat and for: $ while read line; do echo "$line"; done < f1.txt; A=0 A=`expr $A + 1` This will also make the eval run correctly: $ while read line; ...


1

I believe XDMCP is using the fonts local to the Solaris system. When you SSH you're using fonts that are local, since in that scenario you're the X server and the Solaris box is the X client. You can use the command xlsfonts to see what fonts are accessible to you on a given system. EDIT #1 - Font path You can find out your system's font path using the ...


1

This updates the locate database, which will indeed take a long time. It has to traverse every path on the system and then index it appropriately, which requires a lot of work (and a lot of resources). While it's not really possible to speed up population of the database, you can make it less intrusive by increasing the niceness and io-niceness of updatedb. ...


1

Try: $ which startxwin This should tell you that startxwin is here: /usr/bin/startxwin If it's not, then Joseph R's comment is probably correct and you don't have the package installed.


1

That's the iperf2 code base, you might want to try the iperf3 code base. As another alternative to trying to compile this yourself, there's the iperf-cygwin project, which is a project to compile Iperf 2.x on Windows using Cygwin.


1

What is mintty set to use for font and locale? You can find the settings by clicking the top left of the mintty window, select 'Options...' and then click 'text'. Mine is set to Font: Consolas, 11-point. Locale: en_US, Character set: UTF-8. Try that first, then try setting your Locale to Russian.


1

The file /etc/X11/app-defaults/XTerm defines X resources used by Xterm. X resources are configuration values used by old-fashioned X applications (applications that came before modern environments such as Gnome and KDE which have their own, less powerful configuration system). Don't modify the system file. Instead, write your own settings in ~/.Xresources. ...



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