Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
51
views
bbe combine 2 files using blocks
I have 2 files: nand and spare. I need to combine them like this: first 512b from nand + first 16b from spare + second 512b from nand + second 16b from spare + and so on I'm on Kali.
I have 2 files: nand and spare.
I need to combine them like this:
first 512b from nand + first 16b from spare + second 512b from nand + second 16b from spare + and so on
I'm on Kali.
Alex Alexandru
(3 rep)
Jun 26, 2025, 11:04 AM
• Last activity: Jun 26, 2025, 11:29 AM
2
votes
2
answers
256
views
How do I merge a volume group together with my system hard drive?
[![The image show my systemdrive in gparted][1]][1][![A screenshot of blivet gui on my desktop system where the sdd drive is the system drive while all the other are auxiliary drives][2]][2] If you all look at the enclosed image above, you can see that I've merged four hard drives into one volume gr...


TheÆtherIsReal
(29 rep)
Jun 13, 2025, 07:12 AM
• Last activity: Jun 13, 2025, 12:04 PM
44
votes
10
answers
240438
views
How to exit a git merge asking for commit message?
I'm using git. I did a normal merge, but it keeps asking this: # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. And even if I write something, I can't exit from here. I can't find docs explaining this. How shou...
I'm using git. I did a normal merge, but it keeps asking this:
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
And even if I write something, I can't exit from here. I can't find docs explaining this. How should I do?
Luca Reghellin
(729 rep)
Jan 27, 2015, 08:38 AM
• Last activity: Feb 6, 2025, 12:29 PM
3
votes
2
answers
3232
views
How to merge multiple mp4 files as chapters in a final mp4?
I have folder with files named like `0001.mp4`, `0002.mp4`, ... I want to merge all these files to a `combined.mp4`, and I want it to have an internal chapter marks. It is convenient when playing for example in vlc, as you can see the chapter names in timeline. [![enter image description here][1]][1...
I have folder with files named like
How can I make such
0001.mp4
, 0002.mp4
, ...
I want to merge all these files to a combined.mp4
, and I want it to have an internal chapter marks. It is convenient when playing for example in vlc, as you can see the chapter names in timeline.

combined.mp4
? Preferably, command line script using ffmpeg
, and no additional dependencies.
There is similar question, but asker wants to use handbrake.
Ashark
(1069 rep)
May 8, 2023, 12:32 AM
• Last activity: Sep 18, 2024, 02:30 PM
3
votes
1
answers
1062
views
How to merge pdf file so that each file starts with file name?
I have around 500+ files and I know how to merge them. But the problem is I would like to merge them in such a way that every file starts with the file neme in its first page. For example I have 3 files (fila1,file2,file3) and each file has 10,20 and 30 pages. I need the merged file in such a way fi...
I have around 500+ files and I know how to merge them. But the problem is I would like to merge them in such a way that every file starts with the file neme in its first page.
For example I have 3 files (fila1,file2,file3) and each file has 10,20 and 30 pages. I need the merged file in such a way first page would be FILENAME that is file1 then the complete first file , then name of second file in one page followed by the file and so on....
How could I do so?
TCFP HCDG
(115 rep)
Jun 23, 2016, 10:16 AM
• Last activity: Aug 2, 2024, 09:28 AM
2
votes
1
answers
930
views
git, merge changes from another (related) repo (says already up to date)
This is clearly one of those "I've missed the basic principle" type issues. Luckily since everything is now "on the web" I can be very specific and not need to say "for example" (but it's the principle I want to understand). [FYI: This got moved from "stackoverflow" because it's not about programmin...
This is clearly one of those "I've missed the basic principle" type issues. Luckily since everything is now "on the web" I can be very specific and not need to say "for example" (but it's the principle I want to understand).
[FYI: This got moved from "stackoverflow" because it's not about programming ... strictly true I guess ... but mostly for programmers ]
[AFYI: It seems some folks go around searching keyword matches on questions , then posting links to any that match ... so I've already found many links were people did a merge from another repo ... and it worked ...if that was the answer I'd not have posted this question]
I developing some code to drive an e-ink display. The code is at:
https://github.com/waveshareteam/e-Paper
I came across a bug and went to open an "issue" , while there I spotted there were quite a lot of "issues" and a lot of waiting "pull requests". Reading though these I realised I'd quite like some (one for now) in my version.
The one I wanted was : https://github.com/rohoog/e-Paper
(lots of fixes to avoid busy waits)
...Now I didn't do this is the methodical fashion implied here but:
Whereas I had thought the situation I was in was :
So there were no new patches to add.. However when I did the "diff(1)" what I was seeing there the 99+ patches (deltas) that had happened in the original repo.
As you can see what I was expecting to pick up were patches P1-P7 (made up numbers here) because I thought the rohoog fork had rolled up all the changes into his master. I fact they are all separate, so since I want the "wait-pin" work I need patches P3-P5 , so I should merge from the tip of "wait-pin" branch.
Have I got this about right?
Any suggestions as to a simple check I should have done to ensure I spotted the "problem" (my misperception) .
(e.g. I was mostly guessing , working back from github pull request to the [wrong] git branch)
git clone https://github.com/waveshareteam/e-Paper
git remote add rohoog https://github.com/rohoog/e-Paper
git fetch rohoog --tags
I then did:
$ git branch -r
WARNING: terminal is not fully functional
Press RETURN to continue
origin/Development
origin/HEAD -> origin/master
origin/master
rohoog/develop
rohoog/master
rohoog/rohoog/array_overflow
rohoog/rohoog/bmp-reading
rohoog/rohoog/compile-opt
rohoog/rohoog/no-commit-binaries
rohoog/rohoog/wait_pin
$ git checkout rohoog/master
$ find RaspberryPi_JetsonNano > /tmp/rohoog-master-RaspberryPi_JetsonNano
$ git checkout master
$ find RaspberryPi_JetsonNano > /tmp/origin-master-RaspberryPi_JetsonNano
$ diff /tmp/origin-master-RaspberryPi_JetsonNano /tmp/rohoog-master-RaspberryPi_JetsonNano
The diff
returned many differences. So next, I did:
$ git diff origin/master rohoog/master > /tmp/diffs
$ wc /tmp/diffs
561055 1374852 25309866 /tmp/diffs
(so maybe , I'll regret trying to do this ...but let's see ..I only care about a few files)
$ git branch
WARNING: terminal is not fully functional
Press RETURN to continue
* master
$ git merge rohoog/master
Already up to date.
OK...what? How? I can see many people have had similar "blind spots" but it feels like I've followed the guidelines. What am I doing wrong?
Well there are many thousands of lines different, I'd expect something to get changed?
OK, taking comments from @Terdon:
I think the mistake I made was:


GraemeV
(348 rep)
Jun 26, 2024, 07:33 AM
• Last activity: Jul 2, 2024, 11:17 AM
4
votes
1
answers
266
views
Merging with JQ
I am looking to merge two different JSON files into one file - file 1 [ { "namespace": "lerjr-rb26-sandbox-keycloak", "name": "keycloak", "url": "REMOVED" }, { "namespace": "prometheus-brr1-sandbox", "name": "abacus", "url": "REMOVED" }, { "namespace": "prometheus-brr1-sandbox", "name": "keycloak",...
I am looking to merge two different JSON files into one file -
file 1
[
{
"namespace": "lerjr-rb26-sandbox-keycloak",
"name": "keycloak",
"url": "REMOVED"
},
{
"namespace": "prometheus-brr1-sandbox",
"name": "abacus",
"url": "REMOVED"
},
{
"namespace": "prometheus-brr1-sandbox",
"name": "keycloak",
"url": "REMOVED"
},
{
"namespace": "prometheus-nginxredirect-sandbox",
"name": "riskpoynt-redirect444",
"url": "REMOVED"
},
{
"namespace": "prometheus-nginxredirect-sandbox",
"name": "riskpoynt-redirect447",
"url": "REMOVED"
},
{
"namespace": "prometheus-x105-sandbox",
"name": "epas",
"url": "REMOVED"
},
{
"namespace": "prometheus-x105-sandbox",
"name": "epas-oidc",
"url": "REMOVED"
},
{
"namespace": "prometheus-x105-sandbox",
"name": "keycloak",
"url": "REMOVED"
}
]
file 2
[
{
"namespace": "ler-rb26-sandbox",
"labels": {
"pg.customerName": "prometheus",
"pg.customerCode": "rb26",
"pg.product": "keycloak",
"pg.environment": null
}
},
{
"namespace": "lerjr-rb26-sandbox-keycloak",
"labels": {
"pg.customerName": "lerjr",
"pg.customerCode": "rb26",
"pg.product": "keycloak",
"pg.environment": null
}
},
{
"namespace": "prometheus-brr1-sandbox",
"labels": {
"pg.customerName": "prometheus",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
}
}
]
EXPECTED OUTPUT
[
{
"namespace": "lerjr-rb26-sandbox-keycloak",
"labels": {
"pg.customerName": "lerjr",
"pg.customerCode": "rb26",
"pg.product": "keycloak",
"pg.environment": null
},
"ingresses": [
{
"name": "keycloak",
"url": "REMOVED"
}
]
},
{
"namespace": "prometheus-brr1-sandbox",
"labels": {
"pg.customerName": "prometheus",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
},
"ingresses": [
{
"name": "abacus",
"url": "REMOVED"
},
{
"name": "keycloak",
"url": "REMOVED"
}
]
},
{
"namespace": "prometheus-nginxredirect-sandbox",
"labels": {
"pg.customerName": "null",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
},
"ingresses": [
{
"name": "riskpoynt-redirect444",
"url": "REMOVED"
},
{
"name": "riskpoynt-redirect447",
"url": "REMOVED"
}
]
},
{
"namespace": "prometheus-x105-sandbox",
"labels": {
"pg.customerName": "null",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
},
"ingresses": [
{
"name": "epas",
"url": "REMOVED"
},
{
"name": "epas-oidc",
"url": "REMOVED"
},
{
"name": "keycloak",
"url": "REMOVED"
}
]
}
]
NOTE that the final product has labels (null if not present) and if there are no ingresses the namespace entry is removed. the namespace key/value pair is the link between the two files - file 1 is the primary file I suppose, I do not want the namespace entry from file 2 if there is no namespace entry in file 1.
Any and all help would be greatly appreciated I have been struggling with this.
Victor Gonyo
(43 rep)
May 29, 2024, 08:36 PM
• Last activity: Jun 3, 2024, 07:42 AM
1
votes
1
answers
180
views
While sending mail, the body of the mail lines are getting merged in unix
I have to send an email from my development server, the mail body is having some 20 lines. But Few lines are getting merged. I have tried no of scenarios (used mailx,mail & sendmail also) to avoid this, but still the lines in body mail are getting merged. $ cat check.txt Company*+ ! 1000000001!: Glo...
I have to send an email from my development server, the mail body is having some 20 lines. But Few lines are getting merged.
I have tried no of scenarios (used mailx,mail & sendmail also) to avoid this, but still the lines in body mail are getting merged.
$ cat check.txt
Company*+ ! 1000000001!: Global Operations
Last Name* ! 1000000018!: Global Operations
First Name* ! 1000000019!:Generic
**command used to send this mail:**
mailx -s "FAILURE" < check.txt "abc@gmail.com"
**Received Output in mail:**
Company*+ ! 1000000001!: Global Operations Last Name* ! 1000000018!: Global Operations First Name* ! 1000000019!:Generic
Let me know if I am doing any wrong in the code.
user609203
(11 rep)
Apr 29, 2024, 06:47 AM
• Last activity: Apr 29, 2024, 07:04 PM
1
votes
0
answers
51
views
How to merge the content of multiple subdirectories into another directory where destination contains the same directory name using a mount / union?
In the example below, ```exdir``` is a directory containing many subdirectories. The contents of each subdirectory, which are directories themselves, should be merged with ```/su/destdir```, which already contain directories of the same names. The end result, for example, should be a filesystem wher...
In the example below,
is a directory containing many subdirectories. The contents of each subdirectory, which are directories themselves, should be merged with /su/destdir
, which already contain directories of the same names.
The end result, for example, should be a filesystem where /su/destdir/a
contains the files and directories already in /su/destdir/a
, and additionally the files and directories in /home/user/exdir/412/a
, /home/user/exdir/754/a
, and finally /home/user/exdir/612/a
.
Any changes made in /home/user/exdir/*
would thus effect any executable that reads the directory /su/destdir
when this union is active. If not active, the /su/destdir
directory should appear unchanged.
/home/user/exdir/412
└── a
/home/user/exdir/754
├── a
└── b
/home/user/exdir/523
└── c
/home/user/exdir/612
├── a
├── d
├── f
├── c
└── e
/su/destdir
├── a
├── b
├── c
├── d
├── e
├── f
├── g
├── h
├── j
└── k
Dr. Barry
(11 rep)
Nov 22, 2023, 12:26 AM
• Last activity: Nov 22, 2023, 05:56 PM
0
votes
1
answers
2096
views
How to merge two gz files into new outputfile with specific name
I have 96 *fastqc.gz raw read files from 24 samples. Each sample was sequenced on two lanees for each pair. I would like to merge reads for each pair from both lanes into one output file with same name identifier from sample file name (2271_merged_R1_001.fastq.gz). File names are in this order: 22[7...
I have 96 *fastqc.gz raw read files from 24 samples. Each sample was sequenced on two lanees for each pair.
I would like to merge reads for each pair from both lanes into one output file with same name identifier from sample file name (2271_merged_R1_001.fastq.gz).
File names are in this order:
22[71-94]*R[1-2]_001.fastq.gz;
**2271**_ID890_1_S1_L001_**R1_001.fastq.gz**
**2271**_ID890_1_S1_L002_**R1_001.fastq.gz**
**2271**_ID890_1_S1_L001_**R2_001.fastq.gz**
**2271**_ID890_1_S1_L002_**R2_001.fastq.gz**
I tried the following short script but only two output files are being generated (first and the last).
FOR R1 files
for rf in 22[71-94]*R1_001.fastq.gz; do zcat $rf > 22"${71-94}"_merged_R1_001.fastq.gz ; done
FOR R2 files
for rf in 22[71-94]*R2_001.fastq.gz; do zcat $rf > 22"${71-94}"_merged_R2_001.fastq.gz ; done
My Questions are:
1. Why only two output files are generated?
2. The number of reads in the out put files are not the sum of the merged files from both lanes.
3. Is there a nice way, I could do the merging of reads from both lanes for both (R1 and R2) in single step instead of running it two times for each read type.
What went wrong in the code? and how could I verify that the output files are completely merged?
Thanks
TCFP HCDG
(115 rep)
Apr 25, 2018, 03:01 PM
• Last activity: Oct 31, 2023, 09:00 PM
7
votes
3
answers
716
views
Merge files using zipper method / late merge
I am searching for a nice method of merging two or more files line by line using the zipper method (also called late merge). Assuming we have three files, the result should look like this: line1 file1 line1 file2 line1 file3 line2 file1 line2 file2 line2 file3 ... **EDIT** I wrote a little python sc...
I am searching for a nice method of merging two or more files line by line using the zipper method (also called late merge). Assuming we have three files, the result should look like this:
line1 file1
line1 file2
line1 file3
line2 file1
line2 file2
line2 file3
...
**EDIT**
I wrote a little python script capable of doing this:
#!/usr/bin/python
import sys, itertools
fileList = []
for file in sys.argv[1:]:
f = open(file, "r")
fileList.append(f.read().split("\n"))
for z in itertools.izip_longest(*fileList):
print "\n".join([i for i in z if i is not None])
I still wonder if there is any standard tool or a clever combination of them doing the same thing.
scai
(11381 rep)
Aug 11, 2012, 03:44 PM
• Last activity: Oct 28, 2023, 06:04 AM
16
votes
2
answers
18413
views
Command-line diff tool
So we all have the `diff` command installed by default. I certainly don't know how to use it *well*. But I would expect some reasonable default usage. Yet when I type `diff file1 file2` I get ... a text ... which I have to parse in my head ... which is not helped by the fact that this is a weird com...
So we all have the
diff
command installed by default. I certainly don't know how to use it *well*. But I would expect some reasonable default usage. Yet when I type diff file1 file2
I get ... a text ... which I have to parse in my head ... which is not helped by the fact that this is a weird combination of two texts, which are in turn very complex themselves.
So I looked for a graphical solution, e.g. meld
. That works much much better out of the box.
Yet I would prefer to have the luxury of staying on the command line all the time. Is there a fairly standard command which:
- uses colour by default and can adopt syntax highlighting
- presents side-by-side diffs and does 3-way merges by default
- works on the command line, e.g. via libncurses
- depends on neither vim
, emacs
nor an IDE
- can modify edited files in place?
If not, why not? I looked into colordiff
but it doesn't quite cut it.
Vorac
(3197 rep)
Feb 5, 2019, 03:02 PM
• Last activity: Oct 10, 2023, 03:36 PM
3
votes
3
answers
1775
views
concatenate all the text files in all the sub folders into one giant text file
Ok so the situation is that I have an unknown number of sub-directories that all follow the same naming profile folder0, folder1, folder2, folder3 etc Now each folder will have 3 text files and these text files will have the same 3 file names in all folders file1 file2 file3 I would like to find an...
Ok so the situation is that I have an unknown number of sub-directories that all follow the same naming profile
folder0, folder1, folder2, folder3 etc
Now each folder will have 3 text files and these text files will have the same 3 file names in all folders
file1 file2 file3
I would like to find an easy way to concatenate all the text files in all the folders into one text file, starting in folder0 with file1, then file2, then file3 and the same order in all folders.
Now for a small number of folders I could use cat
cat folder0/file1 folder0/file2 folder0/file3 folder1/file1 folder1/file2 folder1/file3 folder2/file1 folder2/file2 folder2/file3 folder3/file1 folder3/file2 folder3/file3 > textfile
but the number of folders is unknown and could range into the 100's or 1000's
anybody have any indea of a script that would acomplish this.
jessyjack
(41 rep)
May 7, 2022, 03:39 PM
• Last activity: Sep 28, 2023, 10:08 PM
0
votes
1
answers
102
views
How to merge all folders in one directory without merging their subfolders?
I have folders arranged as such: ``` Directory -Subdirectory A 1 --Subdirectory B 1 --Subdirectory B 2 -Subdirectory A 2 --Subdirectory B 3 --Subdirectory B 4 ``` How do I merge all the Subdirectory As into one folder without also merging the Subdirectory Bs?
I have folders arranged as such:
Directory
-Subdirectory A 1
--Subdirectory B 1
--Subdirectory B 2
-Subdirectory A 2
--Subdirectory B 3
--Subdirectory B 4
How do I merge all the Subdirectory As into one folder without also merging the Subdirectory Bs?
eldomtom2
(1 rep)
Sep 3, 2023, 10:12 PM
• Last activity: Sep 4, 2023, 02:00 PM
13
votes
5
answers
5596
views
How can I merge pdf files so that each file begins on an odd page number?
I need to merge a few dozed pdfs, and i want all of the input pdfs to start on an odd page in the output pdf. Example: `A.pdf` has 3 pages, `B.pdf` has 4 pages. I _don't want_ my output to have 7 pages. What I want is an 8-page pdf in which pages 1-3 are from `A.pdf`, page 4 is empty, and pages 5-8...
I need to merge a few dozed pdfs, and i want all of the input pdfs to start on an odd page in the output pdf.
Example:
A.pdf
has 3 pages, B.pdf
has 4 pages. I _don't want_ my output to have 7 pages. What I want is an 8-page pdf in which pages 1-3 are from A.pdf
, page 4 is empty, and pages 5-8 are from B.pdf
. How can I do this?
I know about pdftk, but I didn't find such an option in the man page.
Jan Warchoł
(3389 rep)
Feb 28, 2013, 04:04 PM
• Last activity: Sep 3, 2023, 11:13 AM
0
votes
2
answers
621
views
Merge files with same name in multiple subfolders
I have multiple folders with a lot of files, Each folder has txt files of the same name, I want to merge files with the same name into one txt file. Example: ``` folder/ -sub1 -sub2 -sub3 . . . -sub28 ``` In each subfolder has a multiple files: ``` EAF001.ID001.txt EAF001.ID002.txt EAF001.ID003.txt...
I have multiple folders with a lot of files, Each folder has txt files of the same name, I want to merge files with the same name into one txt file.
Example:
folder/
-sub1
-sub2
-sub3
.
.
.
-sub28
In each subfolder has a multiple files:
EAF001.ID001.txt EAF001.ID002.txt EAF001.ID003.txt EAF001.ID004.txt
EAF001.ID005.txt EAF001.ID006.txt EAF001.ID007.txt EAF001.ID008.txt
EAF001.ID009.txt EAF001.ID010.txt EAF001.ID011.txt EAF001.ID012.txt
EAF001.ID013.txt EAF001.ID014.txt EAF001.ID015.txt EAF001.ID016.txt
I want merge files with the same name.
EAF001.ID001.merge.txt EAF001.ID002.merge.txt EAF001.ID003.merge.txt EAF001.ID004.merge.txt
EAF001.ID005.merge.txt EAF001.ID006.merge.txt EAF001.ID007.merge.txt EAF001.ID008.merge.txt
EAF001.ID009.merge.txt EAF001.ID010.merge.txt EAF001.ID011.merge.txt EAF001.ID012.merge.txt
EAF001.ID013.merge.txt EAF001.ID014.merge.txt EAF001.ID015.merge.txt EAF001.ID016.merge.txt
Any help would be much appreciated.
Roq
(15 rep)
Apr 25, 2023, 12:32 AM
• Last activity: Apr 25, 2023, 03:24 AM
4
votes
1
answers
1449
views
Merge JSON arrays on dissimilar keys
I have 2 JSON files with arrays (extracted from restAPI using curl in bash). Both files are arrays with a `.result` object at the top which needs to remain. The first has a `.name` field and many (over 100) other fields including `.ip_address` which is blank. The second has additional information li...
I have 2 JSON files with arrays (extracted from restAPI using curl in bash). Both files are arrays with a
.result
object at the top which needs to remain. The first has a .name
field and many (over 100) other fields including .ip_address
which is blank. The second has additional information like interface and ip address and the name (key) in a different field name. The key in the first file is not the same as the key in the second but should be related (I could change the key field name of course before and the key's data is often mixed case)
I want to merge them so that the first JSON's ip_address
is overwritten where the .name
fields are the same and the additional data added:
I get that it's either multiplying the arrays or reducing and adding but I can't get it right based on the examples already found. For a solution, I would be most grateful.
**Servers:**
{
"result": [
{
"os": "Microsoft Windows Server 2019 Standard",
"name": "SERVER1",
"ip_address": ""
},
{
"os": "Microsoft Windows Server 2019 Standard",
"name": "SERVER2",
"ip_address": ""
},
{
"os": "Microsoft Windows Server 2019 Standard",
"name": "server3",
"ip_address": ""
},
{
"os": "Microsoft Windows Server 2016 Standard",
"name": "server4",
"ip_address": ""
}
]
}
**ips.txt**
{
"result": [
{
"interface": "Intel Wireless-AC 9560 160MHz",
"cmdb.name": "server1",
"ip_address": "10.0.0.10"
},
{
"interface": "Wi-Fi",
"cmdb.name": "server2",
"ip_address": "10.0.0.10"
},
{
"interface": "Intel Dual Band Wireless-AC 8265",
"cmdb.name": "server4",
"ip_address": "10.0.0.10"
}
]
}
**Desired output of Server data is:**
{
"result": [
{
"os": "Microsoft Windows Server 2019 Standard",
"name": "SERVER1",
"interface": "Intel Wireless-AC 9560 160MHz",
"ip_address": "10.0.0.10"
},
{
"os": "Microsoft Windows Server 2019 Standard",
"name": "SERVER2",
"interface": "Wi-Fi",
"ip_address": "10.0.0.10"
},
{
"os": "Microsoft Windows Server 2019 Standard",
"name": "server3",
"ip_address": ""
},
{
"os": "Microsoft Windows Server 2016 Standard",
"name": "server4",
"interface": "Intel Dual Band Wireless-AC 8265",
"ip_address": "10.0.0.10"
}
]
}
BrandonH
(43 rep)
Apr 8, 2023, 02:04 PM
• Last activity: Apr 9, 2023, 08:15 PM
0
votes
2
answers
302
views
Merge two two-column files based on a common first column prefering values from the second column of a given file
I have two text files `1.txt` and `2.txt` that contain two tab separated columns. The first column of both files consists of tokenized text. In both files, the first column is the same. The word order matters. The second column consists of tags. In the first file, the tokenization is complete but im...
I have two text files
1.txt
and 2.txt
that contain two tab separated columns. The first column of both files consists of tokenized text. In both files, the first column is the same. The word order matters. The second column consists of tags. In the first file, the tokenization is complete but imprecise. In the second file, it is incomplete but precise.
1.txt
:
I 3
was 5
there 6
yesterday 6
. 0
2.txt
:
I 3
was
there 12
yesterday
. 0
I want to merge these two files (while maintaining the order of the lines) so that there is a tag on each line and so the more precise (i.e. the tags from file 2.txt
) are preferred as follows:
I 3
was 5
there 12
yesterday 6
. 0
----------
I've tried using join
, but it can display only both of the tags or just the tags from one file:
$ join 1.txt 2.txt
I 3 3
was 5
there 6 12
yesterday 6
. 0 0
$ join -1 1 -2 1 -o 1.1,2.2 1.txt 2.txt
I 3
was
there 12
yesterday
. 0
[This answer](https://unix.stackexchange.com/a/612064/526245) using awk
seems close but doesn't deliver the desired result. I'd also prefer using coreutils.
winety
(3 rep)
Dec 31, 2022, 11:13 AM
• Last activity: Jan 11, 2023, 08:27 PM
0
votes
3
answers
214
views
I want to merge files starts with same name
I have multiple files, more than 100 like below and I need to merge same name files in to 1 file by concatenating them together. ``` AB_HCE_USERS_20221228_001.txt AB_HCE_USERS_20221228_002.txt AB_HCE_TASKS_20221228_001.txt AB_HCE_TASKS_20221228_002.txt AB_HCE_TASKS_20221228_003.txt AB_HCE_ASSESSMENT...
I have multiple files, more than 100 like below and I need to merge same name files in to 1 file by concatenating them together.
AB_HCE_USERS_20221228_001.txt
AB_HCE_USERS_20221228_002.txt
AB_HCE_TASKS_20221228_001.txt
AB_HCE_TASKS_20221228_002.txt
AB_HCE_TASKS_20221228_003.txt
AB_HCE_ASSESSMENTS_20221228_001.txt
AB_HCE_ASSESSMENTS_20221228_002.txt
AB_HCE_CONTACT_20221228_003.txt
AB_HCE_CONTACT_20221228_004.txt
AB_HCE_CONSUMERS_20221228_001.txt
AB_HCE_VERIFICATION_20221228_001.txt
AB_HCE_VERIFICATION_20221228_002.txt
AB_HCE_CONSUMER_RELATIONSHIP_20221228_001.txt
AB_HCE_CONSUMER_RELATIONSHIP_20221228_002.txt
...
Desired output:
AB_HCE_USERS_20221228.txt
AB_HCE_TASKS_20221228.txt
AB_HCE_ASSESSMENTS_20221228.txt
AB_HCE_CONTACT_20221228.txt
AB_HCE_CONSUMERS_20221228.txt
AB_HCE_VERIFICATION_20221228.txt
AB_HCE_CONSUMER_RELATIONSHIP_20221228.txt
..
s v
(27 rep)
Dec 31, 2022, 02:09 AM
• Last activity: Jan 5, 2023, 03:27 PM
-1
votes
2
answers
138
views
Concatenate each two files with awk
I have several files like this ``` BR1.txt NH1.csv BR2.txt NH2.csv BR3.txt NH3.csv ``` and I want to concatenate each `BR` with `NH` in one file.
I have several files like this
BR1.txt
NH1.csv
BR2.txt
NH2.csv
BR3.txt
NH3.csv
and I want to concatenate each BR
with NH
in one file.
Djabri Josef
(335 rep)
Jul 14, 2020, 07:37 PM
• Last activity: Dec 10, 2022, 09:02 PM
Showing page 1 of 20 total questions