Tag Info

New answers tagged

1

Here's a script that will disable the feature completely on a constant basis, regardless of whether that checkbox to preserve windows is checked or not, the windows will not restore. #!/bin/bash echo "#!/bin/bash" > /tmp/loginfix.sh echo "rm /Users/*/Library/Preferences/ByHost/com.apple.loginwindow.*" >> /tmp/loginfix.sh mv /tmp/loginfix.sh ...


0

I ran into the same issue and never got the working directory flag to open zsh in the specified directory. My workaround was to execute a cd command as part of the task's config: C:\CygWin\bin\zsh.exe --login -i -c "cd C:\my\working\directory; exec zsh"


0

I just add the bin directory in the cygwin directory to my Windows Path Environment Variable and then either create a shortcut to: mintty.exe -i /Cygwin-Terminal.ico zsh --login or just change the default cygwin start menu shortcut to the same.


0

I solved it by running the following command on boot: dmesg -n 1


0

You can install ImageMagick utils and use identify command for that. You can install it via brew install ImageMagick. Here is the suggestion how you can use this tool: identify -verbose *.jpg | grep -we ^Image -e exif:DateTime | grep -C1 " [1-5].:..:" It should print the files matching the criteria in format like: Image: Foo.jpg exif:DateTime: ...


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 ...


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 ...


0

You may try using ex: ex +"%s/$/--end/g" -cwq foo.txt which is equivalent to vi -e. Option -i isn't quite compatible between Linux and Unix and it may not be available on other operating systems.


0

ssh has the -o switch, which allows you to provide additional options. Of particular use here is the ConnectTimeout option, which takes an arguement specified in seconds: ssh -o ConnectTimeout=5 123.123.123.123 In addition, ConnectionAttempts might also be useful to you.


0

Close enough: timeout -5s "ssh $line true" That is: Use correct quotes. timeout `ssh …` cannot possibly work here, because it means "run 'ssh', capture its output, then give the output to 'timeout'." Run ssh in "batch" mode, that is, give it a command to run. Without it, ssh will run in interactive mode, and will hang forever even on successful ...


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

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


2

I believe this is how konsole terminal emulator interprets bells. Try to run in bash sleep 3 && echo -e "\a" Then switch to another app and wait 3 seconds. Many many years ago when real terminals were connected to big computers, there was a special protocol called "escape sequences" to send commands to such terminals. There are sequences to ...


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 ...


2

If you just want to replace <author type=''><\/author> with <author type='Local'><\/author>, you can use that sed command: sed "/<fiction type='a'>/,/<\/fiction>/ s/<author type=''><\/author>/<author type='Local'><\/author>/g;" file But, when you dealing with xml, I recommend an xml parser/editor ...


0

It is quite easy with sed. The following script will change the contents of file a.xml and will put the original to a.bak as a backup. What it does is it searches each file for the string <author type=''> and replaces it with <author type='Local'>. The /g modifier means that it will try to make more than 1 replacement on each line if possible ...


0

CMPRS indicates the amount of bytes of compressed data in memory belonging to the process. http://macs.about.com/od/macoperatingsystems/fl/Understanding-Compressed-Memory-in-OS-X.htm


1

You can define a function for this and then use recursion. As an example: #!/bin/bash #Defining hostgen function hostgen() { NEXTHOST=$(sed `perl -e "print int rand(99999)"`"q;d" /usr/share/dict/words) echo $NEXTHOST read -p 'Do you want to use this hostname? (y/n)' variable_name if [ "$variable_name" = "n" ]; then echo "Okay. I ...


0

#!/usr/bin/awk -f { z = 92 - length y = int(z / 2) x = z - y printf "%*s%s%*s\n", x, "", $0, y, "" } Input hello world alpha bravo charlie delta Output hello world alpha bravo charlie delta


0

Add this to your ~/.bashrc. If .bashrc is located in current working directory: PROMPT_COMMAND='if [[ "$bashrc" != "$PWD" && "$PWD" != "$HOME" && -e .bashrc ]]; then bashrc="$PWD"; . .bashrc; fi'


1

Introduction If I understand you correctly, you want to add any directories "$X/node_modules/.bin" where $X is the $PWD or any of its ancestors. The script at the end of this post should give the behaviour you want. You need to source it in every session where you want it. If you name the file augment_path.sh, then adding this line to your .bashrc should ...


2

You do not specify the output format and/or if you want some aggregation functions, but one example script which will create as exit one column file is: for ((i=1;i<25;i++)) do awk '{print $9}' Angle${i}/output.txt >>total.txt done If you want to have 9th column from each file as column you can use script like this: awk '{print $9}' ...


1

The answers touch on the point that the vim directory containing the vim.exe executable need to be added to the path. But for those needing more explicit directions, follow these procedures. 1. Open Control Panel 2. Go to System 3. Click on Advanced system settings 4. In the Advanced tab, click on Environment Variables 5. Highlight Path in System variables ...


0

You can try using ping with its -a switch to resolve IP addresses to hostnames. ping -a 192.168.1.1


1

The TOSTOP option (described for instance in Unix Power Tools, or Linux csh script going to Suspended (tty output) when running with & (bg)) refers to a shell's background processes. In this situation, the foreground and background have a known relationship. However, if your process has opened a terminal, it (almost always) has permissions on it, and ...


2

CTRL + L should do what you want


2

This question has been asked before, with some suggested answers: trim the terminal command prompt working directory on AskUbuntu One suggests setting PROMPT_COMMAND (to in turn set PS1), using a custom script. Another says that if you have bash 4.x, that supports a PROMPT_DIRTRIM variable (and suggests a workaround for older versions of bash). How can I ...


0

For people who find this by Googling for changes to a particular file, the answer is much simpler (inspired by Gilles's answer). If you want to do something after a particular file has been written to, here's how: while true; do inotifywait -e modify /path/to/file # Do something *after* a write occurs, e.g. copy the file /bin/cp /path/to/file ...


0

I think putting the following into your ~/.bashrc will do what you want. If the bash environment variable PROMPT_COMMAND is set to some command, that command is executed before bash displays the primary prompt. In the code below, COMMAND_PROMPT is set to the name of a function, doit. That function checks whether the current working directory has changed and ...


0

You can work with bash's PROMPT_COMMAND: PROMPT_COMMAND='[ -z "$X" ] && X=$PATH; PATH=$X:$(pwd)/node_modules/.bin' That command is executed every time when the prompt apprears. Therefore, everytime when a command finishes, the PATH variable is changed. An additional directory is added to the end. If there is no directory ./node_modules/.bin in ...


1

Instead of xinit use startx. Open rc.local sudo nano /etc/rc.local and use su -l pi -c startx /home/pi/startmidori.sh This solution works for me if i us the PiTFT, but if i connect a display via HDMI it start's only the GUI/Desktop but not Midori.


2

I know this question is quite old, but just in case someone is looking for this functionality, like I was: I recently added this to my LD_PRELOAD module collection (https://github.com/zardus/preeny). Using preeny, you can have a process suspend itself on startup: # https://github.com/zardus/preeny # cd preeny # make # ...


2

You would see the usr directory if your current directory is /. Your home directory, abbreviated as ~, is probably not the root directory but something like /home/adam. When you call cd /usr, you’re using an absolute path, as indicated by the leading slash. This call behaves the same wherever you execute it from. When you call cd usr, you tell cd to change ...


1

Redirect both stdout and stderr to /dev/null: > /dev/null 2>&1 OR in bash: &> /dev/null You can do it for all programs spawned by your script by using exec with the redirection at the beginning of your script. exec > /dev/null 2>&1 Unless the programs you invoke in your script access the terminal directly (rare), this should ...


1

I reflected on @Thomas Dickey's answer via the "guard variable" and your situation. There are some tricky things going on here and it depends on your environment. If you're logged into a workstation running X windows, when you log in, the .bash_profile file is read (typically, though I Cannot say for sure about all editions of Linux; it also depends on ...


0

I'm answering the "prevent fork bomb" question in the title, not the one you actually asked. ;) Put Hard nproc limits in /etc/security/limits.conf as enforced by PAM. Just a suggestion: * soft nproc 500 %users soft nofile 256 But this might just screw with something like Apache or MySQL.


3

You would have to set your own special variable to be tested in .bash_profile, e.g., if [ -z "$IN_MY_SCRIPT" ] then export IN_MY_SCRIPT=$(date) script ~/Logs/$(date "+%Y-%m-%d.%H-%M-%S") fi


4

Maybe i'm getting old but should . and .. not be ignored by any command ? AFAIK these are there because of the filesystem and serve no other purpose. That would make no sense, simply because you specifically fed the names . and .. to chown by your chown <...> .*. In such an instance, why should chown think that you didn't do what you wanted to do? ...


1

Dot (.) can't be ignored because is current directory Double dot (..) (upper directory) will not be ignored because it mach the wildcard But if you exec it on this way you will have not such effect chown -R root:root * If you want to change only hidden files, directories try this: find . -regex '.*/\..*' -exec chown root:root {} \;


1

Way 1: commandline: powershell $w1='D:\games';$w2='D:\music';$s1=(ls -Re -Fo $w1^|Measure -pr length -s).sum;$s2=(ls -Re -Fo $w2^|Measure -pr length -s).sum;if($s1 -gt $s2){explorer $w1}else{explorer $w2} Way 2: MaxCD.cmd: @ECHO OFF SET W1=D:\games SET W2=D:\music powershell $w1='%W1%';$w2='%W2%';$s1=(ls -Re -Fo $w1^|Measure -pr length -s).sum;$s2=(ls ...


0

We ended up solving this in a similar somewhat like Tony suggested in his comment, but the details are different. We created a user login script and set group policy set to run logon scripts synchronously. In the script we have a timeout 8 which is long enough for these machines to come up fully on the network; after the script exits, Windows then ...


0

Just in case it's of help to anyone. It turns out that the way the shell works is that if a current directory is deleted in a different instance of shell, and is then recreated and populated with files, the original shell will show an empty directory. And, if from my-dir (showing no files) you go cd .. cd my-dir you can now see the files. This led to ...


1

This will append to the file: echo "some text" >> someFile.txt This will overwrite to the file: echo "some text" > someFile.txt This will append text from one file to another: cat someFile.txt >> someOtherFile.txt This will overwrite text from one file to another: cat someFile.txt > someOtherFile.txt


0

Typing resize after connecting to the device works for me: shell@android:/ $ resize COLUMNS=192;LINES=44;export COLUMNS LINES;


0

Most *nix systems support a few CLI text editors, the most common of which is vi and vim. See here (and google for about a thousand others) for a tutorial on vi. http://www.howtogeek.com/102468/a-beginners-guide-to-editing-text-files-with-vi/ Another really common one, especially for programmers is emacs. Tutorial here: ...


1

On most OS's this is done with redirect commands, almost always these are > to over-write any existing file, or >> to append to a file. Lookup pipes and redirects for more info. Not a Mac expert but since MacOS is largely unix these days I imagine it will be the same.


0

Create individual files with the desired PATH variable and store them in a directory in your home folder. Example: cat ~/ch_path.d/brew PATH="/usr/local/bin:/(and so on)" export PATH Then you can source whatever path you want source ~/ch_path.d/brew


0

Most likely, your $PATH is set incorrectly. Specify the full path to android, or set your path via something like this: <?php putenv( implode(PATH_SEPARATOR, array('/dir/containing/android', getenv('PATH'))) ); $fname = $_POST['fname']; $fpack = $_POST['fpack']; $email = $_POST['email']; // Create a new Android project var_dump(shell_exec("android ...


1

Depending on how complicated your use-case actually is, you can set and/or change a variable for just one command by prefixing the command with the variable's value. For example, 1 prompt> X=1 2 prompt> X=2 some_command arg1 arg2 3 prompt> echo $X the variable X will be 2 inside some_command, but returned back to X=1 on line 3. So you could ...



Top 50 recent answers are included