# Tag Info

7

I don't think you can do it with join alone. You could do: join -t, -a1 -a2 -o0,1.2,1.3,1.4,1.5,2.2,2.3,2.4,2.5 -e MISSING 1.txt 2.txt | perl -F, -lape '@F[1..2]=@F[5..6] if $F[1] eq "MISSING";$_=join",",@F[0..4],@F[7..8]' -p: use a line by line reading loop like in sed/awk -a, -F,: like awk, split the lines into fields (into the @F ...

5

You can use bash scripting, but for compression etc. it relies on other programs. You might be better of with Python, or any other scripting language which can generate CSV files for you (although CSV syntax is not necessarily difficult to generate), and that can do the concatenation and compression. Given this directory of files (all different length, but ...

5

I'll assume that extra field from the n lines of file2 should be appended to the last n lines of file1: awk -F, -v OFS=, 'FNR==NR {a[FNR]=$3; next} {print$0, a[FNR]}' <(tac file2) <(tac file1) | tac paste -d, <(tac file1) <(cut -d, -f3- <(tac file2)) | tac These solution add a trailing comma to the first line. You can remove it by ...

5

This is definitely feasible. Many of us were running mixed, load-balanced broadband configs for corporate years ago and they worked really well. Many probably still do! You can do it in a number of ways, including using iptables rules and/or iproute2 (ip(8) command) to setup policy routing. The load balancing is not done at the packet level, but at the ...

5

You can use rsync to do this: $rsync -abviuzP src/ dest/ -a archive mode; equals -rlptgoD (no -H,-A,-X) -i turns on the itemized format, which shows more information than the default format -b makes rsync backup files that exist in both folders, appending ~ to the old file. You can control this suffix with --suffix .suf -u makes rsync transfer skip ... 5 awk ' NR==FNR {vals[$1] = $2 " "$3 " " $4; next} !($1 in vals) {vals[$1] = "0 0 0"} {$(NF+1) = vals[$1]; print} ' file2 file1 TABLES REF-IO HEAD-IO DIFF-IO REF-SELECT HEAD-SELECT DIFF-SELECT test 200 500 -300 5 7 -2 exam 2 3 -1 0 7 -7 final 2 1 1 12 6 6 mail 4 2 2 0 0 0 TOTAL 208 506 -298 20 23 -3 5 You can use the bedup utility to de-duplicate the identical files. Once you've installed it, usage is fairly simple: # bedup dedup /path/to/btrfs You may need to set your snapshots writable (btrfs property set -ts /path/to/snapshot ro false) so it can de-duplicate them. You can change them back afterwards. Note that depending on how many files you have, ... 4 What implementation of join are you using? With join (GNU coreutils) 5.97, I can use [0 1021] ~/temp/jointest % join -a1 -a2 jointest1.txt jointest2.txt a 1 10 b 2 11 c 12 d 4 13 e 5 and the "plain" join works, too (but omits c and e). There is an -e option which supposedly lets you choose the marker for empty fields, but it appears to be broken in my ... 4 Use vimdiff if you like vim. Otherwise, diffuse works great as well. 4 You don't need patch for this; it's for extracting changes and sending them on without the unchanged part of the file. The tool for merging two versions of a file is merge, but as @vonbrand wrote, you need the "base" file from which your two versions diverged. To do a merge without it, use diff like this: diff -DVERSION1 file1.xml file2.xml > merged.xml ... 4 If you don't mind the order of output:$ awk -F',' 'NF>1{a[$1] = a[$1]","$2}END{for(i in a){print i""a[i]}}' file jkl, words and numbers, words and numbers, words and numbers, words and numbers abc, 12345, 56345, 15475, 123345 ghi, something else, something else, something else, something else def, text and nos, text and nos, text and nos, text and nos ... 3 The first step is to produce a pdf file with an empty page. You can do this easily with a lot of programs (LibreOffice/OpenOffice, inkscape, (La)TeX, scribus, etc.) Then just include this empty page where needed: pdftk A.pdf empty_page.pdf B.pdf output result.pdf If you want to do this automatically with a script, you can use e.g. pdftk file.pdf ... 3 Yes - bash scripting will be able to meet the requirements. But you should use whatever scripting language you are comfortable with. python, perl are other possibilities. 3 This is a useful1 use of cat:$ cat File1 File2 > CombinedFile Footnotes: 1. As opposed to the useless use of cat

3

The PyPdf library makes this sort of things easy if you're willing to write a bit of Python. Save the code below in a script called pdf-cat-even (or whatever you like), make it executable (chmod +x pdf-cat-even), and run it as a filter (./pdf-cat-even a.pdf b.pdf >concatenated.pdf). You need pyPdf ≥1.13 for the addBlankPage method. #!/usr/bin/env python ...

3

As far as I know, there isn't any universal way; it depends on which version control system you are using, e.g.: Mercurial uses a setting in .hgrc. git uses merge.tool configuration, as told in a comment. for svn, you specify in /etc/subversion/config.

3

I usually use paste from coreutils for this sort of thing: paste -d'\n' file1 file2 file3

3

using just awk: awk -F, -v OFS=, ' BEGIN {m = " MISSING"} # process file1 NR == FNR {lines[$1] =$0; next} # process file2 { added[$1] =$4 OFS $5 if (!($1 in lines)) { $4 = m$5 = m lines[$1] =$0 } } # print the combined output END { for (id in lines) ...

3

The 'x' file: FNR==1 { ++FILENO } { T[$1]++ X[$1,FILENO]=$2 } END { print "type\tvalue1\tvalue2\tdifference" for(t in T) print t"\t"X[t,1]+0"\t"X[t,2]+0"\t"0+X[t,1]-X[t,2] } The run:$ awk -f x file1 file2 type value1 value2 difference viewer 23 2990 -2967 remark 2 240 -238 test 27 0 27 ...

3

Another awk solution: $awk ' FNR==NR { a[$1] = $2; c[$1] = $1; next; } { b[$1] = $2; c[$1] = $1; } END { printf "type\tvalue1\tvalue2\tdifference\n"; for(i in c) printf "%s\t%d\t%d\t%d\n", i, a[i], b[i], a[i]-b[i] }' file1 file2 type value1 value2 difference remark 2 240 -238 test 27 0 27 ... 3 Assuming you're talking about merging 3 partitions into 1 with all the original data intact I do not believe you'll be able to merge these partitions, as they are. There is not enough unused space on any of the partitions that can contain the other partitions' used space. You could shuffle them around and maximize the free space so that it's on 1 of the 3 ... 2 i wrote a little perl script, that do this #!/usr/bin/perl do { open($fh[$_], "<$ARGV[$_]") or die("'$ARGV[$_]' does not exist") } for(0..$#ARGV); for($i=0;;$i++) { $j=$#ARGV+1; $fh =$fh[$i%$j]; if ( $_ = <$fh> ) { print $_; } else {$end |= 2**($i%$j); } if($end == (2**($j))-1) { last; } } ...

2

Another Python version that does not need to read all files into memory at once: paddy$more f[123].tmp :::::::::::::: f1.tmp :::::::::::::: line1 file1 line2 file1 line3 file1 :::::::::::::: f2.tmp :::::::::::::: line1 file2 line2 file2 line3 file2 line4 file2 :::::::::::::: f3.tmp :::::::::::::: line1 file3 line2 file3 line3 file3 line4 file3 line5 file3 ... 2 join -j2 <(sort -k2 file1) <(sort -k2 file2) -o 1.1,1.2,2.1,2.3 | column -t outputs 873 1.1.1.1 test7 p10 1108 78.2.204.174 test8 p4 1257 78.2.8.181 test1 p6 1033 99.99.99.10 test2 p9 2 You can use join for this. First we have to sort both files using the 2nd column as key:$ sort -t' ' -k 2,2 a > as $sort -t' ' -k 2,2 b > bs Resulting in:$ cat as 873 1.1.1.1 1108 78.2.204.174 1257 78.2.8.181 1033 99.99.99.10 $cat bs test7 1.1.1.1 p10 test8 78.2.204.174 p4 test1 78.2.8.181 p6 test2 99.99.99.10 p9 Then the actual join:$ ...

2

merge(1) is probably nearer to what you want, but that requires a common ancestor to your two files. A (dirty!) way of doing it is: Get rid of the first and last lines, use grep(1) to exclude them Smash the results together sort -u leaves a sorted list, eliminates duplicates Replace first/last line Humm... something along the lines: echo ...

2

You can use cp -r name_of_the_folder/* name_of_the_destination_folder where the asterisk(*) stands for all files and -r for recursive copy. You can use also the -i option which will ask you if you want to overwrite the contents.

2

If I understand your question correctly you have the following: $echo -e "line1\nline2\nline3\n" line1 line2 line3$ And you want this: line1line2line3 So you should only need to remove the blank lines. A command like this should do it: \$ echo -e "line1\nline2\nline3\n" | paste -s -d '' line1line2line3 I'm not sure where your output is being kept, ...

1

Gilles' answer worked for me, but since i have to merge many files it's more convenient if i can read their names from a text file. I've slightly modified Gilles' code to do just that, maybe it would help someone else: #!/usr/bin/env python # requires PyPdf library, version 1.13 or above - # its homepage is http://pybrary.net/pyPdf/ # running: ...

1

You could also use LaTeX to do this (though I'm aware it's probably not what you want). Something like the following should work: \documentclass{book} \usepackage{pdfpages} \begin{document} \includepdf[pages=-]{A} \cleardoublepage % Make sure we clear to an odd page \includepdf[pages=-]{B} % This inserts all pages. Or you can specify specific pages, a ...

Only top voted, non community-wiki answers of a minimum length are eligible