Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

4

If I have read your question correctly you seem to be stuck on the fact your mac does not have matching usernames (including root) with your server. You really don't need to use a matching username on the client when logging into or setting up access to a server. If you don't specify a username then the ssh client will assume your current username, but you ...


0

The problem is solved by removing non-ASCII characters from the name of the exe file. It is probably a bug of wine.


1

You can use sw_vers to determine this: $ sw_vers ProductName: Mac OS X ProductVersion: 10.14.5 BuildVersion: 18F132 Or, for a more succinct answer: $ sw_vers | awk '$1 ~ /ProductVersion/ { print $2 }' 10.14.5


1

You should be able to do this using Fedora Media Writer for OS X. Get the dmg file from https://github.com/FedoraQt/MediaWriter/releases


0

You can also use echo inside sed: sed -i "s/$(echo '\t')//g"


0

I created a /tmp/sudoers file with content in John Militer answer and ran a variation of tmm1 command. osascript -e 'do shell script "cat /tmp/sudoers > /etc/sudoers; chown root:wheel /etc/sudoers" with administrator privileges' Nice!!!


4

sed -i backup -E '/<update>/s/[0-9]{4}-[0-9]{2}-[0-9]{2}/2019-06-30/;/<version>/s/[0-9]\.[0-9]{1,2}/1.28/' * -i backup means to edit the files at their place, but keep a backup file with extension backup. You can delete them if the command did what you expected. If it did something else you'll be happy to have the backups! -E is for extended ...


0

If you don't mind typing in two commands, you can use: sed -i 's/\<update\>2013-02-10\<\/update\>/2019-06-30\<\/update\>/g' * sed -i 's/\<version\>1.15/1.28\<\/version\>/g' * In the home directory of where the files are. Alternatively, if you want it to execute recursively: find ./ -type f -exec sed -i 's/\<update\>...


0

Using Miller (https://github.com/johnkerl/miller) mlr --nidx join -j 1 --lp 2 -f input_01.csv then unsparsify then cut -f 1,22 input_02.csv You will have 1234 yxds 4352 fsfk 8765 fdgj 8297 fhjs


0

Use join on sorted files: join -o 1.1,1.2 <(sort file1.csv) <(sort file2.csv) > file3.csv -o 1.1,1.2 means output file1.field1 and file1.field2 Output: 1234 yxds 4352 fsfk 8297 fhjs 8765 fdgj


0

Make 2 files f1 and f2 with the required content and run the following (It will work if you want to include 8297 in the output) sort -k1 f1 > ff1 sort -k1 f2 > ff2 join ff1 ff2 | cut -d ' ' -f1 > t1.txt join ff1 ff2 | cut -d ' ' -f2 > t2.txt paste t1.txt t2.txt > finaloutput.out rm f1 f2 ff1 ff2 finaloutput.out will contain the required ...


3

The cron daemon does not write to /var/mail/$USER, it sends an email to the user whenever a job outputs anything or fails, which in turn is written to that file (the user's mail inbox) by the system's mail delivery service. To turn off the sending of email from the cron daemon, set the MAILTO variable to an empty value in the crontab file: MAILTO="" # ...


3

First sed puts each section on a single line, using the text <EOL> as delimiter between section lines. Then I'm sorting the sections and using the second sed to revert each <EOL> back to a newline. sed -r ':r;$!{N;br};s:\n([[:blank:]])(\1*):<EOL>\1\2:g' file|sort|sed -r '/^$/d;:l;G;s:(.*)<EOL>(.*)(\n):\1\3\2:;tl;$s:\n$::' I didn't ...


3

Using Perl you could run something along the lines of: slurp the file (perl -0n) split the input by not indented lines split(/^(?=\S)/m) sort and print perl -0ne 'print sort split(/^(?=\S)/m) ' ex


0

You could loop over the user accounts and invoke the last command. Here's a little script: #!/bin/bash while read user; do if ! last -5 "$user" | grep "^$user"; then printf "$user\tno session found\n" fi done < <(dscl . list /Users | grep -v '^_') You could also feed multiple user names to last like last user1 user2, but you wouldn'...


0

With zsh specifically, you could do: path[1,0]=(~/projects/{vendor/,node_modules/.}bin(/N)) Where: path[1,0]=(list) inserts the list at the start of the array ($path in zsh is an array tied to $PATH like in zsh). and (N/) is a glob qualifier where N enables nullglob for the glob and / selects files of type directory, so it add those two files ahead of $...


0

Since Phoenix OS did not cooperate, and your CPU is VT-x capable, perhaps virtualizing it, Mac OS X, and Lubuntu under Windows 10 is a viable solution; https://itsfoss.com/install-linux-in-virtualbox/ explains the process using Oracle's free Virtual Box app.


0

As others have pointed out, your code does not necessarily work as you expect when you open a new terminal, as the current working directory may not be the one that contains your projects, and that piece of code is only run when a new shell starts. Instead, you presumably know where your projects are, possibly in relation to your $HOME directory. If so, ...


0

i don't think its possible to do it as you want, not with .rc (.rc is executed only once, it will not be executed later unless you specifically do it). But what about two aliases? backupPATH=$PATH function mkpath { [ -d "$(pwd)/vendor/bin" ] && export PATH="$(pwd)/vendor/bin":"$PATH" [ -d "$(pwd)/node_modules/.bin" ] && export PATH="$...


0

The standard with brew is to put /usr/local/bin on your PATH before system directories like /usr/bin so that it’s commands get picked up first.


-1

if youre talking about GNU readline in the shell you will want to use Ctrl+K to kill to the endof the line. Alternatively you can also use Alt+D to incremently kill on a breaking point Edit: Just realized you're using zsh on Mac. The only server I haveusing zsh is in the cloud. Ill test real quick and verify. Edit: Yes still works for me on Linux Ubuntu. ...


1

First map the key binding by typing bindkey \^U backward-kill-line. Then test to see if this worked. If it works, make it permanent by adding the same line to an appropriate zsh RC file. echo 'bindkey \^U backward-kill-line' >> ~/.zshrc


1

Use an alias. The alias is defined in one of your BASH RC files, such as ~/.bashrc. Below, if /usr/local/bin/vim is a symbolic link, then create an alias called vim. if [ -h '/usr/local/bin/vim' ]; then alias vim='/usr/local/bin/vim' fi The same logic can be applied as follows. [ -h '/usr/local/bin/vim' ] && alias vim='/usr/local/bin/vim' -h ...


0

This answer is good for Unix variants. I am not sure whether it is possible to have multiple virtual consoles on macOS, nor whether bash.bashrc has the same name. OpenBSD might be a good resource? Short background: 2 Types of shells: login and interactive (bash) login shell is what you get when you boot a machine or switch virtual consoles with CTRLALTF1 ...


1

The concise answer is to use a subshell to execute the command in the non-current directory: (cd arg; ls -d *[^~]) But to create a general function that works for the current directory as well as any non-current directory, we can add the following to .bashrc (or to bashrc_aliases_lsBSD, sourced by .bashrc): alias ls='/bin/ls' alias l='' unalias l ...


2

Using bash and its GLOBIGNORE shell variable, together with macOS's basename: $ mkdir dir $ touch dir/file{1,2}{,~} $ ls -R dir ./dir: file1 file1~ file2 file2~ $ GLOBIGNORE=*~ $ ls -d dir/* dir/file1 dir/file2 $ basename -a dir/* file1 file2 Setting GLOBIGNORE to a list of :-delimited patterns will make filename completion ignore those ...


0

You need to put the url in quotes, like this: wget 'https://www.ebi.ac.uk/ena/data/warehouse/filereport?accession=ERS076383&result=read_run&fields=fastq_ftp&download=txt' or escape the ampersands (\&).


1

There are small differences like the missing status option in the BSD dd, but I wouldn't worry too much about that. AFAIK the core options are the same. Run the following commands as root, replace diskX / diskY with your disk identifiers (like disk1 or disk2): # list all disks to find your disk identifier diskutil list # unmount your sd card if it is ...


3

You can do this with find and mv, but it isn't the simplest approach here. You're on macOS, so zsh is preinstalled. Zsh comes with a neat file mass-renaming tool called zmv. Run zsh in a terminal, then in zsh run something like: autoload zmv zmv -n '[^_]#_([0-9])_*' '/elsewhere/${1}/${f}' Explanations: -n tells zmv to display what it would do, but not ...


1

The shell is splitting input on whitespace. You can use bash globbing with the recursive ** to get the filenames split properly: shopt -s globstar for f in **/*_0_*; do mv "$f" /dest/; done If they're all going to the same place, the loop is not needed: shopt -s globstar mv **/*_0_* /dest/ ... or use find -exec, which passes filenames directly from ...


0

I had the same problem after formatting a 8GB pendrive as FAT32 using Disk Utility. After formatting it was displaying -194MB and would format to any other format after that. I was able to recover it using the Terminal and the diskutil tool. First list the current volumes $ diskutil list Then format your USB volume $ sudo diskutil eraseDisk FAT32 MYSD ...


0

Here is an awk script that does the task: Only for printing/debug: awk 'match($0,/(^[^\\.]+.)([^#]+)/,m){print "mv "$0" "m[2] }' input.txt Do the rename: awk 'match($0,/(^[^\\.]+.)([^#]+)/,m){system("mv "$0" "m[2])}' input.txt input.txt p1.uniquenameA#blah_a p2.uniquenameB#blah_b p3.uniquenameC#blah_c p4.uniquenameD#blah_d p5.uniquenameE#blah_e ...


-1

Here is a solution using sed for i in * do mv $i $( echo $i | sed 's/p[[:digit:]]*\.\([^#]*\)\#.*/\1/' ) done The destination is created by using sed by looking for a p followed by any number of digits followed by a period. The characters from the period onwards up to the # character are remembered into a register, and the entire filename is ...


2

If you've got the perl version of rename (sometimes formerly called prename) you can apply a Regular Expression substitution: rename -n 's/^.*?\.(.*?)#.*/$1/' * If you don't understand Regular Expressions (REs) they're very much worth learning. s/xx/yy/ - replace xx with yy ^ - match an implicit start-of-line .*? - match as short a string as possible of ...


0

Mistakes like this is why I wrote a script to automatically backup all of the small text files on my machine every 10 minutes. (also useful if you want to view the previous version of a file) What you're asking is a data recovery question now: Do NOT use the drive for anything else. If it's your main system drive, turn the computer off immediately. You can ...


0

This script will output shell commands that perform a series of 'mv' commands to accomplish your task: for FILE in *.fastq.gz do L="${FILE%%_*}_" R="${FILE#${L}*_}"; printf 'mv -vi "%s" "%s"\n' "$FILE" "$L$R" done Run that once, and examine the output. If there are lots of files, you may want to use less to review the commands. If everything ...


0

You can try something like to rename them: for i in * do o=$(echo $i|awk -F_ '{print $1,$3,$4,$5}') mv "$i" "$o" done


0

Inspired by psusi's answer echo "$(cut -f1 -d' ' your_file.jar.md5) your_file.jar" | md5sum -c - I used cut as not all the md5 are stored in the same way. Example


0

If the directory structure is constant, then wildcards can safely expand the list (assuming there aren't so many resulting files that you exceed the command line length): wc -l main/*/*.txt or wc -l */*/*.txt ... depending on where you're starting from and what you want to include.


3

find /the/path/to/search/ -name "*.txt" -exec wc -l {} \;


-1

find /yourpath -type f -name "*.txt" -exec wc -l {} /dev/null \;


3

Archiving your data is a good option as for the file transfer speed. However, if those images are mostly JPEGs, data is already compressed, and you'll end up wasting CPU time compressing data for a final 1 or 2% gain in file size. This is why you may give a try to tar since it only packs files together without trying to compress them (unless you ask it to ;-...


Top 50 recent answers are included