Tag Info

New answers tagged

0

User Shawn J Goff answered this particular quirk in another question that was the reverse of this one. The answer is here, and as follows: From man sudoers: timestamp_timeout Number of minutes that can elapse before sudo will ask for a passwd again. The timeout may include a fractional component if minute granularity is insufficient, for ...


0

You can use regular expressions instead with JREN.BAT like this: jren "^(dialogue-\d*-)en(\.txt)$" "$1pivot$2" Steps: Copy all the code from this page's post, open notepad and save as jren.txt in the same folder you have those files. Rename jren.txt to jren.bat Open cmd by pressing Windows(Button)+R and type cmd and go to the folder your files are with ...


1

To perform the copy, simply use: for i in dialogue*-en.txt; do cp "$i" "${i/-en.txt}"-pivot.txt;done Or, to see the commands first, use: for i in dialogue*-en.txt; do echo cp "$i" "${i/-en.txt}"-pivot.txt;done The part after the slash simply indicates the string that should be substracted from the original filename. Kudos to ...


0

Apparently, slamming down your fist directly on the trackpad three times is a secret command to tell it to begin working properly. After this, there is no need to disable or move drivers, restart the computer, or plug in additional peripherals.


0

Add this setting to your ~/.inputrc: set revert-all-at-newline on


1

Alt-Space. Then, C. Yeah, it's a bit slower than Ctrl-D. But this the the answer to exactly what you're asking for: the built-in equivalent key-stroke sequence that lets you exit the prompt without needing to type the exit command. No third party software needed. This may not work absolutely identical to bash: bash will only logout on an empty command ...


0

Fixed autohotkey approach. (I cannot add a comment.) #IfWinActive, ahk_class ConsoleWindowClass ^d:: ; First send ESC, in case we're in select mode. Send {Esc}{Esc}exit{Enter} #IfWinActive


2

I don't know how it works but running stty sane usually fixes those kind of terminal issues for me. Shell Prompt Given the description of your problem, I suspect that the issue may be related to your prompt. You have to be careful when setting prompts that include ANSI escape sequences that change colour, etc. Some of them cause bash to think the prompt ...


0

IMO, if you have already done reset than there is really nothing much else you can do. Bite the bullet and start a new terminal session instead. It basically happens to me when/after I wrongly cat the content of binary file to terminal. If it is beyond repair, then it is beyond repair.


4

The above shell script suggested by statox is of course correct, but it does not take into account the fact the computer may go down in between the two checks, or you may logout, or you may interrupt the ssh session from which you are running the script. The simplest way to assure yourself against all these events simultaneously is to use the at command to ...


0

If you want a solution which works always try this: $((`date +%s` % 86400 + $OFFSET )) The $OFFSET should be the difference in seconds between the local timezone and UTC.


2

You could use something like that #!/bin/bash FILE=/home/Savio/Dsktop/check/sample.txt if [ -f $FILE ] then #Do what you want if file exists else sleep 5h if [ ! -f $FILE ] then #Do what you want if the file still doesn't exists fi fi The variable $FILE contains the path of the file you are looking for, it can be modified ...


1

Here's what you need: find -name "(*)*" -type f | rename 's/\(|\)//g' It first finds files in the current directory matching the described name, then renames them by removing the brackets. You can see the matching characters ( and ) are replaced with nothing.


1

Yes, you are. From "man iptables" [!] -i, --in-interface name Name of an interface via which a packet was received (only for packets entering the INPUT, FORWARD and PREROUTING chains). When the "!" argument is used before the interface name, the sense is inverted. If the interface name ends in a "+", then any interface which ...


2

Based on @Michał Górny's answer. Here are the commands to disable num-lock, use numbers anyway, and map numlock to F13 (may be handy to bind to a special function in your window manager). # NumLock is F13 xmodmap -e "remove mod2 = Num_Lock" \ -e "keycode 77 = F13" # Use numbers even when numlock is off xmodmap -e "keysym KP_End = KP_1" \ -e ...


0

Can you check the GNU screen syntax for this line: 3 0 * * * /home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers I would've expected something like: 3 0 * * * /usr/bin/screen -S spaceengineers -X stuff 'command with newline' However, using the -X means screen expects screen commands and not a script to run. Therefore you need to use ...


0

Or just use the floating point support built into ksh #!/usr/bin/ksh v_missedvol=4003.03 v_allvolume=3003.03 v_vol_temp=$(( v_missedvol / v_allvolume )) echo $v_vol_temp


0

Not really: ncurses makes assumptions, and has built-in support for the most common protocols. The most-used is for xterm. ncurses uses the kmous capability to identify the first few characters of the mouse events, but after that, the button-state and coordinates are from the built-in logic. Regarding an "infocmp for mouse codes", in principle one might ...


0

You can use a perl one liner: appendPaths() { # append a group of paths together, leaving out redundancies # use as: export PATH="$(appendPaths "$PATH" "dir1" "dir2") # start at the end: # - join all arguments with :, # - split the result on :, # - pick out non-empty elements which haven't been seen and which are directories, # - ...


2

In some inputrc file (/etc/inputrc, ~/.inputrc, ...) there is a line like: set show-all-if-ambiguous on Remove this line, insert # at beginning of line or change on to off. Alternatively put bind 'set show-all-if-ambiguous off' into your .bashrc Reference: http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC9


-1

It's possible your $HISTFILE is owned by root. Assuming your are using bash as your login shell. Here's how to check: $ [ -z $HISTFILE ] && echo need to set HISTFILE || ls -l $HISTFILE -rw------- 1 root root 36639 May 21 19:48 /home/joeb/.bash_history The default for HISTFILE should be ~/.bash_history, if you see the error "need to set HISTFILE" ...


1

See this Stack Exchange answer. The accepted answer points to this link, which explains how to use pivot_root to create a temporary in-memory root filesystem, which enables you to change, resize, replace or in any other way mess with your root filesystem without reboot.


0

Try: $ ssh -t root@192.168.113.67 "tail -f /var/log/messages" | tee -a mss.txt


0

Another good solution is to install oh-my-zsh, type rm, and tab over to the file you want to delete. ;)


0

Check if your bash script isn't called itself recursively. Don't do that.


0

It seems that the main problem I had was that for most terminal emulators, the command argument is expected to be a single item (i.e., there is no shell-style parsing). For example rxvt -e "ls; sleep 3" fails, even though this is the same way xterm was invoked. If you try to unquote it, that won't work either. For example: rxvt -e ls; sleep 3 is ...


0

I personally use the double-ampersand (&&) and keep everything on one single line if I'm typing. If I'm copying and pasting into a PuTTY window, then I can just copy and paste, and all the commands get executed, as if I typed them in and pressed Enter manually after each line. The additional great thing about the && is that the command will ...


1

The first one isn't going to work in general if at all. Option two is ; but recognise that it says run command one after the other irrespective of whether the first ran successfully. So if first command failed the second one would run anyway. Option three is && which means in your example, run second command only if first command was successful. ...


1

Best is 3rd I think. With the first and second, all but the last command will be executed. Then you'll have to hit enter again.


0

You don't have to do anything special, the CLI sees the invisible carriage return and then goes to the next line. Just highlight, copy, and paste!


-1

You can't disable what was never there.


0

Aside from cmd, those all are X terminal emulators, and most provide some variation of xterm's -e option. Where they differ lies in whether they require the option value to be quoted. Aside from shell limitations, xterm uses all of the tokens past -e as part of the command. They need not be quoted as shown (which makes one token). rxvt follows that ...


1

The Cipher directive is for SSH version 1 (which is not in use nowadays). For SSH version 2, use Ciphers: sftp -oCiphers=aes256-ctr See ssh_config man page. Though note that sftp supports the -c switch too. So there's no need for using -o. See sftp man page: -c cipher Selects the cipher to use for encrypting the data transfers. This option ...


0

You can use inotifytools and its command-line utilities. You can use inotify to monitor directory, and it'll return events for the directory itself, and for files inside the directory. Another tool which can be used is inotifywatch: sudo inotifywatch -v -r /foo You can add -r for to watch all subdirectories recursively. However this solution doesn't ...


1

If your file patterns are that simple, you don't really need a regex, and you can use a simple wildcard: pdfunite handout??.pdf Otherwise, you can use a regex with the find command and -regex, but I could not find a way to execute it that doesn't have the possibility of splitting up into multiple groups of files. Some of the ways you might do it also ...


0

You don't necessarily need a grep. You can pass on the pattern to ls. pdfunite $(ls handout*.pdf*) merged.pdf


1

the "tick" character can be used to do that (the thing above the tilda), I believe. Try something like this: pdfunite [options] `ls | grep "handout...pdf"` From what I understand, that's how you nest a command. Anything inside the ticks is executed as its own command, and the output of it replaces the ticks. So, the command above would essentially ...


1

Try this quite an elegant command: watch -d dir_name


28

In simple terms, a command is an instruction (or a set of instructions) to be carried out by a computer. Stand-alone commands Fundamental Unix utilities such as ls, ln, etc. are (usually) written in C and compiled to be stand-alone executable programs that don’t require an interpreter to be executed; they usually require certain library files to be ...


1

Command just means a way to tell an application or system to do something. An application will typically accept many different commands, either from the GUI, from stdin, but other methods are possible, e.g. a UNIX socket or named pipe, some sort of web API, an RPC connection, or some other custom protocol. An application that does only one thing, then ...


2

A built in command is part of the shell. A program is executed by the shell. Builtin commands are contained within the shell itself. When the name of a builtin command is used as the first word of a simple command (see Simple Commands), the shell executes the command directly, without invoking another program. Builtin commands are necessary to ...


0

In cmd, variables are leaked to the environment by default. You have to surround your commands by setlocal-endlocal to explicitly avoid this. Therefore, you may use the approach suggested by Thomas Dickey to put your environment variables in a .bat file and call that first. We usually do this on Windows machines, by providing a setenv.bat script that we run ...


2

When you first open the terminal, bash runs .bash_profile. You probably have modified .bashrc to add node to your PATH, but that is not executed until you run bash within the terminal. This difference leads to people advising to do this in .bash_profile: [[ -r ~/.bashrc ]] && . ~/.bashrc and on other systems, packagers do this for you as part of ...


0

Let me expand on @00prometheus answer (which is the best one). Maybe you should use a timeout instead of waiting indefinitely. The bash function below will block until the given search term appears or a given timeout is reached. The exit status will be 0 if the string is found within the timeout. wait_str() { local file="$1"; shift local ...


0

Probably not. Your use of "&" in a cmd call is about as close as you could get. You might be able to make it look a little cleaner using call for the "activate.bat" script. Because call does not stop the "parent" batch-program, that is closer to the shell "source" which was requested. I use this in batch-files which build up environment variables ...


1

This bash function will block until the given file appears or a given timeout is reached. The exit status will be 0 if the file exists; if it doesn't, the exit status will reflect how many seconds the function has waited. wait_file() { local file="$1"; shift local wait_seconds="${1:-10}"; shift # 10 seconds as default timeout until test ...


0

Depending on your exact use case and constraints, ondir may suit your needs: ondir is a small program to automate tasks specific to certain directories. It works by executing scripts in directories when you enter and leave them. It does this by using a central ~/.ondirrc file for per-dir configuration. In contrast, the clever PROMPT_COMMAND setup that ...


0

If you are dealing with $1 $2 $3 you can do: for each do echo "$each" done For a traditional array: for each in "${alpha[@]}" do echo "$each" done Note that with the traditional way: printf '%s\n' "${alpha[@]}" This will print a newline even if the array is empty $ alpha=() $ printf '%s\n' "${alpha[@]}" | wc 1 0 1 The for ...


1

To move all folders for years from 1980 to 1995, inclusive, run: shopt -s nullglob mv *'('{1980..1995}*/ /some/path/ The shopt -s nullglob command is not strictly necessary but it eliminates error messages if any of the years are missing. The above uses brace expansions, {1980..1995} to generate all the years explicitly. You can see how brace expansion ...


1

It's probably telling qsub to execute the command in the current working directory. pwd is the shell command "print working directory", which just reports what your current working directory is. Putting that command in `backticks` tells the shell to execute that command in a sub-shell and insert its output into the command line in that place. So if ...



Top 50 recent answers are included