Tag Info

New answers tagged

0

The newline for sed's append is break it, so you have to backslash newline or sustitute by \n symbol: sed -i '' '/user_pref("mail.identity.id1.reply_on_top", 1);/ a\ user_pref("mail.identity.id1.sig_file", "/Users/illias.seba/Library/Mail/V2/MailData/Signatures/signature.html");\ user_pref("mail.identity.id1.sig_file-rel", ...


4

When you run > /tmp/foo.txt, you are overwriting the contents of /tmp/foo.txt with the output of sed 's/old text/new text/' file1.txt. Since /tmp/foo.txt doesn't exist when you run this command, bash will create that file for you and then write it. Then, when you use the -p flag to cp, you are copying the permissions and attributes of /tmp/foo.txt to ...


1

I found the solution and in the end it was pretty simple, I just couldn't see the forrest for the tree. Find out the actual username on Windows by going to Computer Managamenet -> Local Users and Groups -> Users. Account should be listed there with the real name. Then use this name instead of the Microsoft account one and all should work.


1

If I correctly understood the question this can be done quite simply with find . -mtime +5 -exec bash -c 'echo "${0%/*}"' {} \; | sort | uniq


1

I believe that this will do what you need. It looks through each directory in turn and checks that there are no "recently modified" files. find * -type d | while read DIR do LINES=$(find "$DIR" -maxdepth 1 -type f -mtime -5 -print -quit) test -z "$LINES" && echo "$DIR NOT RECENTLY MODIFIED" done If the find ... ...


1

You can use gdb to do this: gdb --batch -ex 'handle all print' -ex 'handle all nostop' -ex 'handle all pass' -ex 'run' cat will run cat under GDB and print all signals, pass them to the program and not stop execution. Doing this for a background program is harder, as GDB will try and go into the background instead. You might be better off starting it with ...


0

If the problem is just with that one package you could download a newer version directly from Oracle. The version in the Mint repository is couple versions back.


1

You exactly got what you asked for: an .mp4 file, which is an extension used for the container format MPEG-4 Part 14. ffmpeg did what you asked it to do. The MP4 files (short for MPEG-4 Part 14, often with extension .mp4) are recognised then by your desktop, by parsing the header, but probably not the content. The desktop therefore does not distinguish ...


3

Try: for f in ./*.txt; do sed -i '' -e "s/$/$(printf '\t')$f/g" "$f" done


0

Under GNU/Linux systems running Xorg (on Wayland maybe will be different) you can use xinput as James R said, and as explained here: http://unix.stackexchange.com/a/17172/48798 On Mac OS X you can disable your keyboard using kextunload command like this: sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyb ...


10

This is by design: programs that produce colored output typically do so only when their output goes to a terminal, not when it's sent to a pipe or to a regular file. The reason is that data sent on a terminal is presumably read by a human, whereas data piped to a program or written to a file is likely to be parsed by some program, so it shouldn't contain ...


-1

I can't comment @jimmij 's answer, because I have less than 50 rep, but I would like to explain what worked for me on bash. If you run man ls | grep color you will see all the entries of the man-page for your specific shell environment (in our case bash). For me the following adjustment did the trick: alias ls='ls -G'


16

The problem most probably is that your ls has set option --color to auto which basically means that output should be coloured only if it is connected to terminal, otherwise (output connected to a pipe or a file) no colors are emitted. If you want to have colors is such cases you should set --color option to always, so try ls --color=always | less -R If ...


0

/tmp is a Virtual File System such as sysfs. Before any action you have to umount /tmp/, then remove it. However almost all Unix OSes need it, so I don't know why you want to remove /tmp. UPDATE: In GNU\Linux OS: /tmp didn't mount and if you grep in mount: root@debian:~# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type ...


3

I think you're just trying to copy files from the server behind NAT via gatewayserver. I'd suggest you more simple solution. Set up password-less authentication (put private key from your desktop/Mac to both mentioned servers) Use smth like ssh -MNf -L 60022:storageserver:22 username@gatewayserver to set up ssh tunnel via gatewayserver. Now your Mac's ...


3

Better idea might be to use sudo instead of su. The prompt change is important because it reminds you that you have elevated privileges and could easily accidentally break something, so you should be careful.


0

If you look at Shell Script for logging into a ssh server you'll notice that the shebang line is #!/usr/bin/expect This is an expect script, not a bash script. You'll need to install Expect if you don't already have it.


0

At the beginning I had set my default shell to chsh -s /usr/local/bin/zsh This shell is installed by brew. Obviously tab completion does not work in this shell. After I switched to the default system zsh in osx, chsh -s /bin/zsh Tab completion works.


2

The OS X version of date uses the -f option to parse a formatted date/time: date -j -f '%Y%m%d' "$1" +'%Y%m%d' The -j option causes it to just print the time, not try to set the system clock. So the full script would be: #!/bin/bash echo "$1"; startd=$(date -j -f '%Y%m%d' "$1" +'%Y%m%d'); echo "$startd"; Here's a transcript: $ ./testdate.sh 20151010 ...


1

If you are trying to format date on OS X, you can try this: date -j -f "%Y%m%d" "20151010" I get the following output: Sat Oct 10 17:27:28 CDT 2015


0

Most systems at this point use a symlink of vi to the vim program. Calling the program in this manner enables some functionality and disables other modes of operation. More to the point, you note that you're wanting to utilize the paste functions in vi. I'm going to make the assumption that you're using vi on Mac OSX in the terminal program. To utilize the ...


1

From your description I suspect you're looking for enabling Paste mode in Vim. You may do this as follows: :set paste It can be disabled with :set nopaste This mode is useful when you copy-paste some code snippet from your OS buffer to Vim. This will prevent Vim from adding lots of extra spaces to line beginnings making pasted text look ugly.


0

Based on http://www.gnu.org/software/parallel/man.html#EXAMPLE:-Grepping-n-lines-for-m-regular-expressions parallel -k parallel --pipepart --block 100M -a file2 -k grep {} :::: file1 Simpler and maybe faster: parallel -j0 -k grep {} file2 :::: file1


0

When you run a class in Java, you need to give the full package name and class name, and be in the right place for that to match the folder and file name. So in your case, declare package cert; in your class as you did initially, build it, then run it as follows: cd ~/Desktop/OCA_Practice java cert.Test


3

grep -F -f needles.txt haystack.log is what you want. -F makes grep use simple pattern matching, if you do not need full regex. This tends to be a HUGE speedup. Depending on what you're searching for, you might not need regex, so might as well get the benefits of faster execution of simpler code. -f is a file of patterns you're looking for. So instead ...


2

My answer is quoted from this stackoverflow question The fastest and easiest way to get "new identity" is send HUP signal. Tor daemon re-read configurations files and make "new identity". I keep special bash script for this: # cat /usr/local/bin/nym #!/bin/bash pidof tor | xargs sudo kill -HUP My sudoers file full of NOPASSWD: # cat ...


5

There is other way to make things faster: Use grep -f file1 file2 >output.txt. You could also use gnu parallel: http://www.gnu.org/software/parallel/parallel_tutorial.html


0

Also, I was thinking, you could edit the script to explicitly use BASH by inserting a: #!/pathtobash/ in the script as the first line e.g. #!/bin/bash or do an explicit /pathtobash/scripttorun call e.g. /bin/bash/scripttorun


0

Your ~/Library, ~/Documents, ~/Applications ... etc are all created with 700 as permission. Locate will skip them. If you want them to be included in your locate database, change the permission to 755. chmod 755 ~/Library sudo /usr/libexec/locate.updatedb


1

On Mac OS 10.10.2, look at /etc/locate.rc file for the PRUNEPATHS field. From Apple's man page for locate.updatedb: DESCRIPTION The locate.updatedb utility updates the database used by locate(1). It is typically run once a week by the /System/Library/LaunchDaemons/com.apple.locate.plist job. The contents of the newly built database can be ...


1

In OS X, the PATH environment variable is build with path_helper. This utility reads the contents of the file /etc/paths and the files in the directory /etc/paths.d to build the PATH environment variable. Initially the /etc/paths.d directory is empty and the content of /etc/paths is /usr/bin /bin /usr/sbin /sbin /usr/local/bin In consequence, the ...


3

You could set a variable in the script which starts fish to note that you're "in fish": export IN_FISH=yes Then, before that, you check whether it's already set: if [ "${IN_FISH}" != "yes" ]; then export IN_FISH=yes fish # replace with the command you use to start fish fi Thus, in your first bash, IN_FISH isn't set, so it gets set and fish is ...


0

Im not sure what the error was but this fixed it: cd `brew --prefix` git reset --hard FETCH_HEAD Then I could brew update just fine.


2

If compatibility with "all Unix systems" is an absolute requirement -- and if it isn't, why are you writing a shell script? -- then, yes, you should be using #! /bin/sh, because Bash is not guaranteed to be installed anywhere, let alone in /bin. It's actually much, much worse than that. If you need compatibility to all Unix systems, that includes things ...


7

For starters, if you can make the assumption that Bash is preinstalled (which, to my knowledge is the case on all the systems you list), use the following hashbang to be compatible: #!/usr/bin/env bash this invokes whatever bash happens to be configured, no matter whether it's in /bin or /usr/local/bin. While on most systems across a wide range ...


4

Yes, both OSX and Linux will come with /bin/bash. You should be perfectly safe. However, that is not POSIX. The POSIX shell is at /bin/sh on most (all?) systems and that is the most portable approach and the only way to be POSIX compatible. Note that while on many systems /bin/sh points to bash, on others it can point to different shells. It's a symlink to ...


7

In Debian and Ubuntu, /bin/sh is dash, which is a POSIX-compliant shell. If you specify #!/bin/sh, you must limit yourself to POSIX statements in your script. (The advantage being that dash starts faster than bash, so your script can get its job done in less time.) On many (most?) other Linux systems, /bin/sh is bash, which is why many scripts are written ...


1

You need to create the package file __init__.py in the directory dir.


1

It seems I found this thread too late, but for future readers of this thread: When doing data rescue, your first step should be to do a full image of the drive with dd or something similar (cloneZilla is a popular choice). In other words, get an imprint of the drive as-is so that you do no further damage to the volume whilst trying to rescue the data.


1

mv id_rsa idnew_rsa;mv id_rsa.pub idnew_rsa.pub;cat idnew_rsa.pub|ssh user@host 'cat>> ~/.ssh/authorized_keys' will do. There's nothing in the file name, only content matters. ssh -i idnew_rsa user@host


1

Add this to your ~/.ssh/config file: Host * IdentityFile ~/.ssh/id_whatever Now ssh will (also) try to use that file when connecting to a host. You can limit this to a particular host by naming it explicitly instead of using *.


3

Generally speaking SSH keys identify clients, not servers (well, at least for the keys in ~/.ssh). The recommended approach is to generate one key per client, as you’ve done effectively, and to add all the appropriate public keys to ~/.ssh/authorized_keys on the servers/accounts you need to access. So on your Macbook Pro, you wouldn’t add the new server’s ...


1

If using zsh, you can sort the list numerically with: printf '%s\n' *.txt(n) That's similar to GNU sort -v or GNU ls's -v sorting: ls -vd -- *.txt That sorts f2 before f10, but g1 after f2. To sort a list stored in a zsh array (as opposed to files in the current directory with globbing): files=( f1.txt f10.txt f2.txt ) printf '%s\n' ${(n)files} ...


2

GNU sort with -n option using strnumcmp() which does not do numeric conversions (See numcompare() function). This's purely string comparison. When your key field does not start with a number, the last resort sort sorts byte by byte, you will get the result alphabetic order base on your locale. Example: $ LC_ALL=en_US.utf8 sort -n test.txt f10.txt f1.txt ...


6

I recommend to use rather sort -V data.txt -V stands for "version sort" and it basically handles correctly both alphabetical and numerical characters, so that if you would have more files, say: f1.txt f10.txt f2.txt a1.txt a10.txt a2.txt then sort -V will give you a1.txt a2.txt a10.txt f1.txt f2.txt f10.txt whereas sort -k 1.2n or sort -n -k 1.2: ...


4

Because your data lines don't start with a number, the -numeric sort treats them as non-numbers (and so leaves them where they are). As soon as it stops being possible to interpret the data as a number -n stops caring. You need to use the -keyed sort option: sort -k 1.2n data.txt That sorts with a key defined by the first field, starting at the second ...


1

> sort -n -t . -k 1.2 file f1.txt f2.txt f10.txt Works even without the -t ..


3

OSX does not have the same version of utilities as Linux. The common denominator you can count on is POSIX, which defines cal but none of its options. There are two common versions of cal on Linux: the one from util-linux (e.g. on Fedora) and the one from FreeBSD (e.g. on Ubuntu). Both have the -3 option. OSX is based on FreeBSD, but its version is an older ...


3

You can accomplish this by setting ignoredups in the HISTCONTROL environment variable: export HISTCONTROL="ignoredups" From the bash manpage: HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space ...



Top 50 recent answers are included