All Questions
20 questions
1
vote
1
answer
1k
views
Compare two files and get the matching rows based on two columns
I have two pipe delimited file like below
file1.txt
A1234|JESSIE|OPTED
A1224|JOHN|OPTED
L1212|RAMSAY|OPTED
L1832|TIZEN|TESTED
file2.txt
A1234|B1465
G1211|L1211
G1241|L1212
G1271|L1232
Desired output
...
2
votes
3
answers
209
views
Find N Most Frequent Words in a File and How to Handle Hyphen?
Let's say we have a file having following text:
hello hel-
lo world wor-
ld test test he-
lo words words
If we just use the space as the delimiter, we would have
hello: 1
world: 1
wor:1
ld:1
he: 1
...
1
vote
2
answers
227
views
Delete column if all entries after the header are a certain string
I have a file of data that looks like this
Sample1 Sample2 Sample3 Sample4 Sample5 Sample6
./. ./. ./. ./. ./. ./.
./. ./. ./. ./. A/G ./.
./. ./. ...
0
votes
1
answer
7k
views
How can I remove patterns using sed command in a file?
I have a document and I want to remove all the patterns so that I stay with only some information, the producer/creator of that document.
I managed to replace patterns with one word "PATTERN" so that ...
3
votes
4
answers
3k
views
How to move string from one line to another
I have been editing a large text file containing pairs of lines as follows (repeated):
\> destination_file.txt
js -e "var e='.jpg',t='b',i='14712583',h='0.us.is.example.com',s='/',n='WIV',u='...
2
votes
3
answers
2k
views
Add mtime to grep -c output and sort the output by mtime
I have a directory full of logs named in the following style:
info.log00001
info.log00002
info.log00003
...
info.log09999
info.log
My current output (using grep -c)
I need to analyze the frequency ...
0
votes
2
answers
1k
views
How do I find a range of numbers in the content of file and move files containing the range of numbers to another directory?
Okay so I have about 90 files, each with a body like
187942 78.9
I want to filter files that has the values between 70 to 90 on the second column and move them to another directory.
12
votes
2
answers
13k
views
How to redirect the output of a command to an already existing file without deleting its contents? [duplicate]
I am making a backup of some files and am creating a checksum file, checksums.txt, to later check the integrity of my data. However pasting each checksum manually into the file is inconvenient since ...
0
votes
2
answers
147
views
Merge Two files depending on a Column, nth occurrence of a string in the column of file 1 to be merged with nth occurrence
Merge Two files depending on a column, nth occurrence of a string in column1 of file1 should be merged with nth occurrence of the same string in column1 of file2. I tried join but the results are not ...
1
vote
1
answer
2k
views
Compare columns between different files
I have multiple files ( about 20 files with 30000 lines and 32 columns) and I need to keep only the lines that start with the same string.
I found these cases that are quite similar to what I need but ...
2
votes
1
answer
723
views
Merge text files with 1st column and difference in output file
File 1: (text1.txt)
Row_Added_Ts Count
01/01/14 2022448
02/01/14 8345155
03/01/14 8663852
04/01/14 6785739
05/01/14 5279913
File 2: (text2.txt)...
6
votes
5
answers
9k
views
How to add an attribute in a tag in XML file by command-line?
I am trying to add field at the end of tag using sed script. Suppose I have a tag in XML file:
<book name="Sed tutorial" price="250"/>
Now I want to add field as Book_Width="A" after end of <...
3
votes
4
answers
8k
views
Find the last occurence of a string in a given filetype in all subdirectories
I have multiple sub-directories each with different depths. I need to search for the last occurrence of a string in a specific file type (say *.out). How can I accomplish this?
I have tried:
grep -r ...
0
votes
1
answer
1k
views
Search a file for a string in multiple directories
Can someone please help me with a command to search a file for a string in multiple directories? I am searching for the VIP in httpd.conf in multiple httpd instances.
I am using:
find ./ -name "...
3
votes
4
answers
2k
views
Fastest way to read last line within pattern of multiple files with the same extension
I have in a directory /home/files/ some files that all have the same extension .txt.
For example
1.txt
2.txt
3.txt
4.txt
5.txt
test.txt
These files are all the same in data format but the data are ...