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.)

learn more… | top users | synonyms

0
votes
0answers
12 views

Are there NLP tools for text analysis?

Are there any tools on Ubuntu that can be used for Natural Language Processing? I am not necessarily looking for R, python or java scripts (thought they could be valuable), but for command line tools. ...
2
votes
1answer
272 views

How do I grep for multiple patterns on multiple lines?

To be precise Some text begin Some text goes here. end Some more text and I want to extract entire block that starts from "begin" till "end". with awk we can do like awk '/begin/,/end/' text. How ...
6
votes
3answers
446 views

How to grep lines, based on a certain pattern?

Let's say I have a file containing following two lines: 2014-05-05 09:11:53 /aa/bbbb/cccccc 29899 2014-05-05 09:12:17 /aa/bbbb/cccccc?dddddddd 16767 I need to get ...
4
votes
4answers
355 views

How to find all patterns between two characters?

I'm trying to find all patterns between a pair of double quotes. Let say I have a file with contents look like as following: first matched is "One". the second is here"Two " and here are in second ...
2
votes
4answers
384 views

Comparing two text files

I have 2 big csv files, file1.csv which looks like this 1,2,3,4 1,4,5,6 1,7,8,9 1,11,13,17 file2.csv which looks like this 1,2,3,4 1,7,8,9 2,4,9,10 13,14,17,18 These are just random numbers that ...
22
votes
4answers
2k views

How to “cat” or “less” a libreoffice writer .odt file?

Is there a way to cat or less a .odt file just as antiword does for .doc files?
1
vote
4answers
125 views

extract text from a file using terminal?

I want to process the body of text and extract an integer from a specific position in the text, but I'm not sure how to describe that 'particular position'. Regular expressions really confuse me. I ...
1
vote
1answer
46 views

Printing footers using enscript

I have a working bash script which converts text files to postscript using enscript 1.6.5.90-2 on Kubuntu 14.04. It does several other things to make the output look better like setting margins, ...
1
vote
1answer
66 views

Insert text blocks everywhere

In german you start mails and letters with "Sehr geehrter Herr ....". I am tired of typing this again and again. And I am tired of configuring applications to give me shortcuts to insert text blocks ...
5
votes
3answers
192 views

How to compare output of a running process?

I am running a benchmark on gem5 simulator, which keeps printing output to terminal while its running. I already stored a sample run of the same benchmark in a text file. So now I want to compare the ...
0
votes
1answer
44 views

How can I make a script for opening a predefined set of .txt files on gedit at startup?

Unfortunately as of late a lot of gedit plugins have stopped working for me, including the session saver. I wanted to find an easy solution to this problem and then it came to me that I can just ...
2
votes
5answers
531 views

How to transform valid JSON to CSV?

I'm trying to extract information from a JSON file and write some of the contents to a CSV file. Here is an example of my text "data":{"headers":{"sender":"frank@abc.com" "to":"jim@def.com" ...
2
votes
2answers
71 views

Sed matching problem, output not as expected

What I need to accomplish: I want to recursively match everything from string1 to fixed_string (both included) on text_files and output the results onto a result_file. My command is as follow: sed ...
5
votes
2answers
227 views

How to save matched pattern into variable using 'sed' command?

I'm trying to find a pattern using sed command in file.txt between first char1 and char2 and then replace that with string. like below with echo mode example: echo "This X is test Y. But X is not ...
1
vote
3answers
65 views

csv file adding and removing characters from rows [closed]

I have a big csv full that looks like so else if(a,b,c,d,e) else if(a,b,c,d,f) I want to make it look like so else if(a+x==b and b+x==c and c+x==d and d+x==e) else if(a+x==b and b+x==c and c+x==d ...
1
vote
2answers
234 views

How to grep for groups of n digits, but no more than n?

I'm learning Linux, and I have a challenge that I seem to fail to solve on my own. Here it is: grep a line from a file which contains 4 numbers in a row but not more than 4. I'm not sure how to ...
2
votes
2answers
82 views

Change text in many files

I have a C++ project, where each file has at its beginning some lines of license. Now, that my license have changed, I need to update it in each file. I don't want to do it manually, since its lots of ...
1
vote
2answers
78 views

Looping through csv, removing patterns

I have a question similar to my earlier question, but a bit different say you have 10 columns on each line, and 100000 lines, I want to check if each row for the following patterns: If a row looks ...
1
vote
3answers
46 views

split string with a certain character to form a path

I have a string abc_d_e75_f10_xyz_l_11 I want to split it so that I want to construct a string of an existing directory from this string to cd to it. So in this example abc_d_e75_f10_xyz_l_11 I want ...
1
vote
4answers
119 views

using sed replace the new line with character

I am using sed command to remove the new line and replace with <br> but I am not able to get the desire output. I wrote : find . -name $1 -print0 | xargs -0 sed -i '' -e 's|\n|ABC|g' but ...
3
votes
4answers
155 views

How can I get the names contained in the first file that are not i?

I have two files containing billions of DNA sequence names, the second is a proper subset of the first: for example, 1°:john mike anna paul laura .... 2°:john mike paul ... all the names occupy ...
14
votes
5answers
1k views

How to display a random line from a text file?

I am trying to write a shell script. The idea is to select a single line at random from text file and display it as an Ubuntu desktop notification. But I want different lines to be selected each time ...
4
votes
5answers
314 views

Shorten lines, adding “…” ellipsis

How to cut off lines that are longer than some width, and marking the lines that were chopped off with an ellipsis? Only lines that were actually shortened should be marked, but not lines that had ...
8
votes
4answers
756 views

How can I repeat the content of a file n times?

I'm trying to benchmark to compare two different ways of processing a file. I have a small amount of input data but in order to get good comparisons, I need to repeat the tests a number of times. ...
9
votes
9answers
2k views

Remove the first part of a string using sed

How do I get from this: randomcollege-nt\user90 to this: user90 using sed?
2
votes
2answers
270 views

How do I get `tr` command to ignore newline?

I want to replace multiple spaces by a single space. I am using tr to do this. But it is also replacing new line with a space. How can I avoid it? Code: tr -s [:space:] ' ' Input: He llo Wor ld ...
0
votes
2answers
63 views

Sorting two columns with sort and uniq

I have a file that needs sorting in a specific way but I can't figure out how to do it. I've tried the following command but it doesn't give me what I want: sort -t" " -k1,1 Original_File | uniq ...
2
votes
3answers
616 views

Reverse all words in current line

I have a file and I want to reverse all word in it. ex input file: DCBA. HGFE.GI MLK,PON.RQ UTS. ZYXWV. 321 ex output file: (What I Want) ABCD. EFGH.IG KLM,NOP.QR STU. VWXYZ. 123 With this sed ...
0
votes
5answers
366 views

Compare strings in two files

I am trying to get the name of the user from one file and their corresponding details from my other file. I use awk: awk -F : '{ print $1 }' user-name it gives me the list of all the user's. So ...
4
votes
3answers
362 views

Searching for patterns in csv files

I have file.csv that looks like this 4,6,18,23,26 5,12,19,29,31 2,5,13,16,30 9,10,24,27,32 4,5,10,19,22 4,6,8,10,25 2,3,4,25,11 I want to find some patterns and save them in another log file ...
9
votes
4answers
466 views

How to delete words from txt file, that exists on another txt file?

File a.txt has about 100k words, each words is in new line july.cpp windows.exe ttm.rar document.zip File b.txt has 150k words, one word by line - some words are from file a.txt, but some words are ...
5
votes
2answers
355 views

Remove text that I don't want

I have a big html file on my desktop that looks like src="http://images.alaablubnan.com/images/Balls/20.jpg" ...
2
votes
2answers
138 views

How to add one column to the another file

suppose this is my file which its name is myFile1 1 10 2 20 3 30 4 40 5 50 6 60 know I want to add my another columns to this. This column is on the file which is myFile2. 10 11 12 13 14 15 16 . ...
4
votes
6answers
250 views

Bash script programming: how to match pattern in string?

How I can get this whole value 7I45432ZX from below lines: PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 This is the code I tried: grep ...
3
votes
2answers
311 views

Find a word using AWK

Is there a way to find a specific record among the whole line? This is my file: one two three four two three four five three four five six four five six seven five six seven eight How do I search ...
1
vote
2answers
285 views

Get unique values and their counts in a column

I have a column like this. Streptococcus Ecoli Bcoli Ecoli streptococcus Streptococcus Mycobacterium Ecoli I want a file like this (which includes all unique values and their corresponding counts) ...
1
vote
2answers
4k views

Add/edit line text in file without open editor (linux command) [duplicate]

I know how to add new text to a file, but how can I edit it? Example: adding hello_world = 1 to test.txt using the following command: echo "hello_world = 1" >> test.txt But how can I change ...
4
votes
5answers
658 views

Remove letters and dots from all lines

I have a CSV that has the output of time commands of different programs including the ID of the execution. Therefore my files contain records in the following form: ID,execution_time Example ...
1
vote
1answer
70 views

Parse git log by modified files

I have been told to make git messages for each modified file all one line so I can use grep to find all changes to that file. For instance: $git commit -a modified: path/to/file.cpp/.h - 1) ...
4
votes
3answers
949 views

Deleting first column with vim

I have a text file. number 1_1 \t number1_2 \t etc number 2_1 \t number2_2 \t etc I want to remove the first column of this file (corresponding to number1_1, number2_1 etc, ie the numbers before ...
1
vote
3answers
163 views

How to split the contents of a file?

I have a text file which contains exactly thousand lines. I want to split the file into 1000 different files by writing each line to a separate text file. And i want the name of splitted files to be ...
4
votes
2answers
477 views

What is the meaning of :a;$!N; in a sed command?

$ (echo hello; echo there) | sed ':a;$!N;s/\n/string/;ta' hellostringthere Above sed command replaces new line character with the string "string". But I don't know the meaning of ...
3
votes
4answers
1k views

How to replace spaces with newlines/enter in a text-file?

I have simple text file named "example". Reading with terminal command: cat example Output: abc cdef ghi jk lmnopq rst uv wxyz I want to convert (transform) into following form: (expected output ...
2
votes
2answers
126 views

Create keyboard shortcuts for certain symbols (like logical operators)

(using Ubuntu 12.04) currently I'm dealing a lot with logic (not for computer science, though), so my idea was to create specific shortcuts on my keyboard for easy typing. my idea is to use Ctrl + ...
0
votes
3answers
150 views

Awk scripting help

Hey guys new to scripting and looking to see why I get the following error message: syntax error near unexpected token '$0' using this .sh file to rearrange date and time in a .txt file so that ...
4
votes
8answers
601 views

How to sort by row from terminal

I was looking at this question and I wondered if the following could be done from terminal. I did it in python, just want to see if it could be done from terminal, bash scripting or whatever. ...
1
vote
3answers
100 views

Forming IPAddresses from Text file

I have a huge text file that contains IP addresses scrambled all over but not in one unit for example. So what the@192@ heck are you doing@168@ in my house @10@.you were not @16@ supposed to be ...
1
vote
3answers
738 views

Remove quotes around integers in a csv file

In a large (>1 gb) csv file I have something like "34432", "name", "0", "very long description" but instead of that I'd like to have 34432, "name", 0, "very long description". I was looking at ...
2
votes
1answer
1k views

using Sed to search and replace text in XML file

I have the following text in File.XML: <!--UpdateAccountGUIDs>UpdateAndExit</UpdateAccountGUIDs--> I would like to replace that with ...
2
votes
1answer
306 views

How can I delete a multi-line record from a text file?

For example test.txt contains: Hi Hello Hi world The code below removes a word from test.txt and creates a temp file test_removed.txt which contains the: #!/bin/bash echo -n Enter Input: read ...