New answers tagged

3

Don't use echo to see what command is being executed. It prints the command after parsing, that is after quotes and escapes have been applied and removed); therefore, if the output of echo includes quotes and/or escapes like you'd expect to see in a raw command line (i.e. before parsing), it indicates that something is terribly wrong. Compare the output from ...


1

The develop mode of setup.py will link your local code path to PYTHONPATH. If you install the local package by python setup.py develop , which will alter the system PYTHONPATH and drive you crazy to delete it from environment variables. I find a correct way to uninstall them and restore your default PYTHONPATH from here. You need use the --uninstall or -u ...


0

It's probably a different version of the file command with a different magic file /usr/share/file/magic.mgc (see the source files /usr/share/file/magic/database for the "dBase III" definitions and /usr/share/file/magic/python for python) or your pyc files are different (different python version and/or code) and file has a false match on Jenkins. Have you ...


0

You can doit as follows : first paste the files together, then run awk to filter out the desired lines. $ nf1=$(<file1 awk '{print NF;exit}') $ paste file1 file2 | awk -vnf1="$nf1" '$(4+nf1)<=$2 && $3<=$(5+nf1)'


0

#!/usr/bin/perl use strict; my $f1=shift; open(F1,"<",$f1) || die "Couldn't open $f1: $!\n"; my $f2=shift; open(F2,"<",$f2) || die "Couldn't open $f2: $!\n"; until (eof(F1) || eof(F2)) { my @a = split /\t/,<F1>; my @b = split /\t/,<F2>; chomp($a[@a-1]); # note: perl arrays start from 0, not 1 print join("\t",@a, @b) if (($a[1]...


0

This is probably not the most efficient awk script: awk '{ if (NR==FNR) { l[NR]=$0 a[NR]=$2 b[NR]=$3 } else if (a[FNR]>=$4 && b[FNR]<=$5) { print l[FNR],$0 } }' file1 file2 > newfile When the first file is read (NR==FNR), save the whole line $0 and fields $2 and $3 in arrays at index NR (record number). When the ...


0

I would advise using Conda. It allows you to create a virtual python environment in whatever version you want.


1

gnome-terminal 3.27.1 introduced the --wait option, which solves this issue. So just run: $ gnome-terminal --wait -e sh -c "python scraper.py"


1

Here is what finally worked for me (on Ubuntu 18.04). The /home/username/start_script.sh (don't forget the chmod +x for that file): #!/bin/bash set -x set -e byobu list-sessions | grep my-app || byobu new-session -d -s my-app byobu list-windows -t my-app | grep start-script || byobu new-window -t my-app -n 'start-script' byobu send-keys -t my-app:start-...


1

This behaviour is caused by TMux sourcing ~/.profile instead of ~/.bashrc. My ~/.profile is this: # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$...


0

$ awk ' NR==FNR {a[$1]++; a[$2]++; next}; !($2 in a)' fusions.head16.R2.fastq.tab test.head20.R2.fastq.tab @10000000_0_0_0_0 rupesh TCCCTACTCACGTGGTGGACGCACAACCTAAGGTCAAGCTTATAGGTAAACACGCAGTGAAATATCCAGAAACGAAGCTATCACCCGGGTAGTGTCTTGG + =FGIIIFDCCDDDCAA5BBBBGIJIIGJIJJJJJJIIGGHHIIIJIJIIJJIEE8?DDECGGIEDDDDDDHHJJJJJJIGIIIJED?CB5@CFFHHHCFF @...


0

Assuming your input is, or can be e.g by sorting, grouped on the $1 values as shown in your input: $ cat tst.awk BEGIN { FS=OFS="," } $1 != prev { if (NR>1) print rec; rec=prev=$1 } { rec = rec OFS $2 } END { print rec } . $ awk -f tst.awk file 71w - Rus,51200 71w - Phi,307200 71w - Ukr,307200,51200 71w - Mic,102400,51200 71w - Jul,256000,51200 71w - ...


0

You can pass an array to Python adding it as arguments and use sys.argv[1:] inside python to read it. Giving back to bash is a bit tricky when your values may contain spaces or newlines, but you could use newline-separated output of python together with readline. arr=(0) readarray -t arr < <(python -c ' import sys arr=sys.argv[1:] arr.append(1) arr....


0

Try something like this: arr=(0) ret="$(python -c 'from pyscript import fun;print fun(arr)' "${arr[@]}")" mapfile -t arr <<<"$ret" # assign returned array from python script to bash array It assumes that your python script takes its input from the command line and stores each argument into the python array arr. Unless your python script is just ...


2

Using GNU datamash: $ datamash -t, -g 1 collapse 2 < file.csv 71w - Rus,51200 71w - Phi,307200 71w - Ukr,307200,51200 71w - Mic,102400,51200 71w - Jul,256000,51200 71w - Pro,256000 71w - Uni,51200 71w - Ind,50176,40960 71w - Sin,358400 71w - May,20480 71w - Tha,512000,972800 71w - Bar,1280000,102400,2048000 71w - Upg,358400 71w - Leg,20480 71w - Res,...


3

A good way to do this is to use an associative array or hash. The key for each hash is the first field (I'll call them "ids", for want of a better term), and the values stored for each key will either be a string containing a comma-separated list of values seen for that id, or an array containing the same. awk: This awk version uses a comma-separated ...


1

You can test this from the command line fairly easily: # set up test mkdir A mkdir B echo "this is A" > A/test.txt echo "this is B" > B/test.txt echo "this is A" > A/old.txt echo "this is B" > B/new.txt # contents of A change on copy ln -s A S cat S/test.txt cp -r B/ A/ cat S/test.txt cat A/test.txt # S still points to A ls -l S/ ls -l A/ ls -...


1

The symbolic link S points to A by means of the path to A. Copying files into A (which is what your command is doing) will not affect this link. If you, for whatever reason, renamed or removed A, then the symbolic link S would be broken and unusable. If you then created something else, possibly a new directory, called A in the same location as the old A, ...


0

Imagine that you had a file called S.txt (in some separate directory) that said The information that you’re looking for is in directory A. It wouldn’t be affected by anything you did to directory A. Symbolic links are very much like this.  The symbolic link won’t be affected by anything you do to its target.


Top 50 recent answers are included