Questions tagged [text-processing]

Questions about modifying, creating or parsing plain text files. This is a very broad tag, if your question is about using a specific tool, please tag it with the tool's name as well (e.g. sed, awk, perl, etc.)

Filter by
Sorted by
Tagged with
0
votes
3answers
70 views

keep header from file1 and add column from file2 to file1

I need to copy a specific column from file2 to my file1, while keeping the header from file1. File1: ##header ##header ##header A1 B1 C1 A2 B2 C2 File2: D1 E1 F1 D2 E2 F2 newfile: ##header ##header #...
0
votes
0answers
30 views

How to make the output of command “tor” to print the last word which is “Done”? [duplicate]

When I run the command tor in cli it shows something like this: May 10 22:41:08.743 [notice] Tor 0.4.5.7 running on Linux with Libevent 2.1.12-stable, OpenSSL 1.1.1k, Zlib 1.2.11, Liblzma 5.2.5, ...
0
votes
1answer
58 views

How do I do these conditional bashes?

I have a .txt file, it contains many names, each in its own separate line. With conditional bashes I have to echo a "Yes" or "No" to the following: Is there a repeating name? Is ...
0
votes
1answer
107 views

How to slice a tuple using variable indexes, output as textual list

I am using Ubuntu 18.04 and Python 3.8 I need tuple_slice() to do 2 things: slice an input tuple between the given start and all BEFORE the end indexes Concatenate these values as a comma separated ...
0
votes
1answer
31 views

Search and replace one domain with another in many files

I need to search for a domain (domain1.it) and replace with a other domain (domain2.com), in many files, a lot. I tried with sudo find '/abc/abc/' -type f -exec sed 's/domain1\it/domain2\com/g' '{}' \;...
0
votes
1answer
50 views

Changes in AWK on Ubuntu 20.04 LTS?

I am working with some huge astronomical databases and I just realized that awk is not working as expected. I'm downloading and cutting some .gz files, but awk restrictions are weird, let me share a ...
0
votes
1answer
35 views

replace headers of files using a different file that has the name information

I have a couple of fasta files (OG000*.fas) files that I need to rename the headers (i.e. all the values after the ">"). The tricky part is that the string that I need to replace in each ...
1
vote
2answers
43 views

Backslash missing in file while replace the string content using backslash contain variable

I want to write backslashes in a file, and I try to substitute some text with the value from a variable: $ TEST=\\etc\\hello $ echo $TEST \etc\hello But the backslash is missing when I tying to ...
-2
votes
1answer
64 views

How to reverse a string in bash script?

I have a string like that: |abcdefg| and I want to reverse this String gfedcba Is that possible in bash?
2
votes
1answer
81 views

How to “cat” or “less” a libreoffice impress .odp file?

Is there any way to cat or less a .odp file just like we have for .odt files as mentioned here
0
votes
0answers
19 views

Evolution consistently displays badly formatted text

Ubuntu 20.04 Evolution seems unable to properly format text in message content. See picture. This can be seen in earlier versions of Evolution as well.
14
votes
4answers
1k views

How can I display the rest of a file starting from a matching line?

I want to display a line matching a search term and all the remaining lines in the file. For example, if I use: more text.txt | egrep show it will only show the line that has "show" in it, ...
0
votes
1answer
28 views

I can't make SORT with multiple columns work

sort -t ';' -k1,1 -k2,2 -k3,3 < unsorted (only column-1 in file 'unsorted' is sorted correct) 11;13;08 12;23;24 14;16;15 17;09;04
1
vote
1answer
39 views

How to print awk's results with different colors for different fields?

ads2 cls create | awk -F [\"] '/^>>> cluster established .../ { strt=1 } strt!=1 { next } $1 ~ "name" { cnt++;nam[cnt]=$2 } $1 ~ "state" {stat[cnt]=$2;print -e "...
1
vote
1answer
37 views

repeated set of lines

A set of 3 lines in my .txt file many sets are one after the other. For example: 1.message: afcdd77f17519b364c1992095399d 2.signature: bbfecd2f9f1c2fabedb3d15f310 3.----------- 1.message: ...
1
vote
1answer
55 views

awk - compare two files and print all columns from both files

I want to compare two files File 1: evm.TU.PTPU-T1. PF00808 evm.TU.PTP-T1 PF00498 evm.TU.PTPX-T1 PF00250 evm.TU.PAN-T1 PF00817 File 2: PF00808 CL0012 Histone CBFD_NFYB_HMF ...
0
votes
1answer
30 views

Bash script get/extract specific info/word from a line

the command nvcc --version outputs the following: nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Wed_Oct_23_21:14:42_PDT_2019 Cuda compilation tools, release ...
0
votes
1answer
38 views

sed edit string between spefic paragraph in a file

I hava a file called a.txt. And it contains the following contents. It's unknow how many lines between each function. function a( line 1; line 2; line ...; properties pro = "test"; ) ...
1
vote
2answers
521 views

Bash alternative to trim newline \n and extra white-space

I am trying to parse a multiline sentence: You have to go tomorrow by car. As you can see there is a new line + space then "car." I used this regex: ...
0
votes
1answer
64 views

Extract frequency value from last column depending on what letter is there to plot

I have a tab-delimited file that has frequency values in the last column (actually the values are tab-delimited as well). I have mostly two values (e.g., A:0 G:1) but some rows have three values (e.g....
-2
votes
3answers
257 views

How can we replace * with 1/2-1/2 or 1-0 or 0-1 at the end of last line(content) of each and every text file within same directory?

I have succeeded in several operations of text files with guidance of you friends. Firstly thank you very much for helping me with commands. Now, I wish to move further in these operations on text ...
0
votes
3answers
29 views

Replace all lines in vim with whatever is after the last slash on a line

I have sample data like: aaa/bbb/ccc/ddd/eee/fff aaa/bbb/ccc/ddd/eee/fff/gg aaa/bbb/ccc/ddd/eee/fff/gg/hhhhh How can I parse out only: fff gg hhhhh with vim or bash? Thanks
2
votes
1answer
165 views

Kill all process by name running over one hour via terminal

I'm currently tying to kill all the process with the name /ebook-convert/ in them that are running over an hour. When I try this command, I get that the process don't exist. kill $(ps -eo pid,etimes,...
1
vote
3answers
252 views

How to remove duplicates and print only those lines that contain a string and has the highest value in a specific column

For example in the below example I want to remove the duplicate ids from the second column and print only those ids that have the highest value in the third column MS1199089 PT01000001.1.1 0.63 16.4 0....
1
vote
3answers
486 views

How can we append asterisk (*) at the end of last line(content) of each and every text file within same directory in Ubuntu 20.10?

I have many text files in a directory. I want to append/add * at the end of last line (content) of each and every text file of the directory with the extension .txt How can this be achieved in Ubuntu ...
0
votes
0answers
48 views

Simple note taking app on Ubuntu that allows markdown and copy paste of tables in spreadhseet format

(tag suggestions welcome) I've been exploring note taking apps, including those listed here and here. Preference is a foss app. I installed Simplenote which seems nice but already does more than I ...
0
votes
1answer
84 views

How can I quote special characters contained inside XML tags?

is possible by simple way replace string (sed) limited inside 2 strings? Example I have xml feed contains many tags, including <DESCRIPTION> tag with special chars inside. I need change special ...
2
votes
1answer
148 views

Terminal command to dump the next N lines of a file after a line containing X?

I want to dump the 10 lines of a file after the line containing "THE_WORD". Is there a clever command line one-liner for this? The best I can come up with is this but it displays all lines ...
5
votes
2answers
377 views

awk if find pattern skip n lines

How to skip N lines when a pattern is found in awk? awk '{if ($0~/pattern/) skip N lines; else print $0}'
10
votes
1answer
608 views

Convert a .txt file in a .csv with a row every 3 lines

Let's say I have a txt file like this: Mario mario@me.com +399038259953 Luigi luigi@live.com +395902385093 Yoshi yoshi@yahoo.com +81293565291 [and so on for 300 lines...] How do I make a .ods (or ....
2
votes
1answer
120 views

Bash script to update BIND ACL - unwanted character

I am trying to update a file on a server where the new line needs to have a single tab at the front but new to bash scripting and sed and keep getting an unwanted character at the front. This is the ...
1
vote
2answers
145 views

Regularly extract text between pattern from text file

I have a huge text file (10GB) formatted as follow (multimodel PDB file): Model 1 ... (some text) ENDMDL Model 2 ... (some text) ENDMDL Model 3 ... (some text) ENDMDL ... Model 9999 ... (some text) ...
2
votes
1answer
39 views

How to grep series title from list of paths?

I have the following command: find /home/cas/plex-media/series/ -type f -name '*.srt' | grep -v .en.srt Which will find all .srt files, that are not .en.srt in the directory and subdirectories of ...
-2
votes
2answers
195 views

Replace only last occurrence of a string using perl command

I have a stdout or a file does not matter: mela pera banana caffè mela pera banana caffè mela pera banana caffè I want remove only last occurrence of "mela" using perl: mela pera banana ...
0
votes
1answer
117 views

Grep -v doesn't work when piping with locate

I have the following command: locate -br '^test.sh$' The output is: /home/cas/scripts/test.sh I want to have the path without the name of the file. So I did the following to remove test.sh from the ...
0
votes
0answers
47 views

Search for a keyword(ABCDG-123*) and store that matched keyword in subsequent column in csv file

I'm trying to do a partial search for a keyword (alphanumeric with spl characters like this ABCD-) available in a column in CSV file. If the searched keyword matches in the column, then the matched ...
0
votes
0answers
27 views

How to use JEdit to find the Xpath location of an element in an XML file?

How do I find the location path for a particular node: where jedit was suggested as an xml viewer.
0
votes
1answer
45 views

AWK to compare columns in file1 to file2

I have a simple problem but have not been able to solve. I want to compare columns 2, 3, 4, 5 and 6 of File1 to the same columns of File2 and if they match then add Column1 of File2 to Column7 of ...
0
votes
0answers
39 views

Delete text log after X days

I have some log files #beginingoffile deny 1.1.1.1; # 12-01-2020-02:01 deny 1.1.1.2; # 12-03-2020-05:55 deny 1.1.1.3; # 12-08-2020-05:04 deny 5.5.5.5; #endoffile The text format is $(date +"%m-%...
1
vote
2answers
53 views

How to extract IP addresses from a file if listed more than X times

I would like to extract IP addresses that meet the requirements of Containing foo Listed in the file more than 5 times Example of my log below 2020/12/07 03:25:16 [error] 31385#31385: *4283 limiting ...
1
vote
2answers
81 views

awk condition is not working properly

These are the data on which I am applying an awk command: ~$ cat lab4.data Mike Harrington: (510) 548-1278:250:100:175 Christian Dobbins: (408) 538-2358:155:90:201 Susan Dalsass: (206) 654-6279:250:60:...
0
votes
1answer
63 views

How to generate a new log file containing the MAC adress based on pihole.log which didn't contain it by default

I have a /var/log/pihole.log that contains lines like these: Nov 29 18:49:33 dnsmasq[13568]: query[AAAA] firebaselogging-pa.googleapis.com from 192.168.0.10 Nov 29 18:49:33 dnsmasq[13568]: query[A] ...
0
votes
2answers
54 views

Remove LF from a specific column using sed

I have a file which contains data separated by |. Example: (Input) a|b|c|d`LF` D|e a1|b1|c1|d1`LF` d2|e1\n Output: (Removed LF from 4th column) a|b|c|dD|e a1|b1|c1|d1d2|e1\n I want to remove LF from ...
0
votes
0answers
38 views

matching single and double quotes in grep using -E [duplicate]

For practicing how grep works in Ubuntu terminal, I made one .txt file: '"..asdf_-_-..34'""'"'" jd8m***ns'''_**''x;';nn*?/...; ++..++ ./,/;]_+))(+_)((*+_":|.<"{}...
4
votes
4answers
625 views

Swapping one character in filename with another

I have a file that has the name a_b-c-d-e-f.txt. I would like to take that current name and swap the dashes and underscores so that it becomes a-b_c_d_e_f.txt. My intuition tells me to try rename or ...
2
votes
1answer
92 views

What is the default encoding, used in text files in Ubuntu?

I created a normal text file "input.txt" in Ubuntu. I added some data to it. My questions are: What is the default encoding, used in text files in Ubuntu? How do I find its encoding ...
1
vote
4answers
258 views

Bash: grep including newline

Trying to regex everything between two braces { }. Similar problem to Regex to match any character including newline - Vi & Vim, but I don't understand the solution provided. Using: nft list ...
-1
votes
1answer
53 views

Compare two columns strings if exist both columns remove those two records

10/27/20 LGVD LGVD-DLV1 ---(LGVD repated 6th line so do not disply it) 10/26/20 LPKK LPKK-DLV1 10/28/20 LFLZ LFLZ-DEV1 ---(LFLZ-DEV1 repeated 8th line so do not disply it) 11/02/20 LFLZ LFLZ-...
7
votes
5answers
2k views

Print 2nd line in text file

I have a file that is returning the following text: 10.10.10.160:1111 10.10.10.170:2222 10.10.10.180:3333 grep -m 1 -o '.*' filename | cut -d ':' -f I tried the above and I can get just 1 single ...
-2
votes
1answer
133 views

How can I remove a space from a text file?

I have a text file with spaces ("= ") to delete. What can I do? The text is as follows: " Cayce fundó la _As= ociación para la Investigación y la Iluminación (ARE) sin fines de lucro en ...

1
2 3 4 5
20