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

4
votes
3answers
81 views

Replace words in file 2, getting the list of replacements from file 1

Cat File 1 ABC,23 DFG,45 Ghj,678 Cat File2 Listed LinkedIn yellow ABC Fixed DFG linked ABC Holiday Europe Ghj DFG I need the output as below Listed LinkedIn yellow 23 Fixed 45 linked 23 Holiday ...
1
vote
3answers
56 views

How to append string before and after a line using sed

I have lines form a command output as given below. service:clus1-svr clus1-node2 started [Z] service:clus1-svr clus1-node2 started I ...
3
votes
2answers
68 views

How to split the lines in a text file into two consecutive lines in a new file?

I have a find -exec grep command pair that groups path/filename.ext:ln#:line contents on a single line. I want to divide the line into two consecutive lines in a second file. The consecutive lines ...
1
vote
3answers
92 views

sed command to replace a value in config file

I am using this command: sed -i 's/\(^TestT_STOA_TS1901=\).*/\1N/'/app/test/must/untuio.cf And I am getting this error: XXXXXXXXX:/app/test/must>sed -i ...
1
vote
4answers
233 views

Reformatting tables

I have the following type of tables: ID date DailyFlow a 1972-01-01 17.0265761797993 b 1972-01-02 17.200476457399 c 1972-01-03 17.2926436045271 d 1972-01-04 17.3900277599829 e 1972-01-05 ...
0
votes
0answers
18 views

Help with sed script to remove Wikipedia citation numbers

I am just beginning to learn sed and awk. I have to submit an homework assignment tomorrow, which is a copy-paste from Wikipedia. Just the opportunity to practice some sed scripting! So I have the ...
-1
votes
2answers
63 views

Something with .txt File? [duplicate]

I have stored a text as .txt while saving it in Gedit in Ubuntu 14.04. But after viewing that folder, which i have stored will have two files with that name but with 'Tilde Symbol' '~' for an ...
2
votes
4answers
129 views

Remove any trailing blank lines or lines with whitespaces from end of file

I want to get delete all of the blank lines and lines with spaces (if any exist (ONLY from the bottom of the file)) and then to remove one more line (also ONLY from the bottom of the file). I have ...
18
votes
7answers
648 views

How to edit multiple text files with a single command?

I want to remove the first line of multiple text files and replace it with another line. Is there a way to do this using the terminal? I know how to use vim, is there a way to automate it with it? I ...
2
votes
2answers
102 views

How to merge values from two different text files?

I have following data set in text files: file1.txt a1:b1 a2:b2 a3:b3 a4:b4 a5:b5 file2.txt b2:c1 b4:c2 b5:c3 How to merge these values to make output file like this: output.txt a2:c1 a4:c2 ...
1
vote
2answers
54 views

How do I find and replace in file1 with values from file2

file1 O,tested test,12345 OC,test explore,34567 file2 O,new order OC,new quote I need an output like below: New order,tested test,12345 New quote,test explore,34567
3
votes
1answer
72 views

Is there any tool for creating custom right-click-menu entries, that run Python scripts?

I would like to be able to go anywhere (google chrome, sublime text editor, etc), then highlight + right click on some text, then click a custom right-click-menu button which will run a python script ...
1
vote
2answers
50 views

How can I get a list with the packages selected by apt-get autoremove?

Is there any command that prints only the name of the packages that apt-get autoremove selects? I'm creating a script that updates the kernel, removes the old kernel and the unnecessary packages ...
2
votes
1answer
185 views

How to mark matching GREP string while redirecting output to file

I am trying to use grep to find all matching strings in file and output them, in context of the line, to another file, while adding some kind of marks (ideally two asterisks) on each side of the ...
2
votes
3answers
304 views

How can I change ##-## space to ##-## tab?

I have a list of entries that begin with 2 numbers, a dash, 2 numbers and a single space. For example (note the space after the numbers): 87-17 I need to change the above to 87-17<tab> ...
5
votes
3answers
205 views

Filter out html tag and replace with other html tags using sed

I was replacing <B> and </B> with <STRONG> and </STRONG> in a file. It's somewhat like replacing hmtl tags. I used sed 's/\<B\>/STRONG/g'. It did the job but if in file ...
1
vote
1answer
25 views

remove a tab e at the end of a line

printf "%s\t" HEMES n{1..1600} >file_a sed -i 's/\t*$//' file_a > file_a removes a tab which is caused at the end of the line after the first line of the code (where the stuff is printed) . ...
1
vote
1answer
36 views

Replace only certain matches of a string search

Further to my earlier question: Search and replace multiple files including subdirectories I wish to make some adjustment so I do not invalidate the CFML. Basically I am trying to avoid nested ...
0
votes
2answers
45 views

How do I remove comments of files?

I have a dir with many files. I want to remove all the comments of that files. How do I do that? The files looks like this (everything what is between the /* and the */ are comment): /* */ ...
0
votes
0answers
19 views

Any editor with CTRL+R binding for compiling LaTeX

I just had to replace my OSX with Ubuntu 14.04 and I want to find ways to get Textmate's capabilities to some text-editor: CMD+R compiles the document in Textmates and let's you choose different ...
5
votes
3answers
265 views

How to remove domain part of each line from text file containing email addresses

I have a text file with one email address per line. How can I remove the domain part but not the TLD part of each line? In here, we would define TLD to be the last element of the string after the last ...
2
votes
5answers
79 views

Add particular strings to an array sed/awk/grep

I have this ciscoFlashCopyStatus OBJECT-TYPE SYNTAX INTEGER { copyOperationPending(0), copyInProgress(1), ...
1
vote
1answer
31 views

Storing some strings in a array

I have this sCSISmart1 TRAP-TYPE ENTERPRISE cyclone VARIABLES {cycHostAdapterNumber, cycHostAdapterID, cycManagerID} DESCRIPTION ...
0
votes
3answers
60 views

get rid of character

printf "%s\t" Nt n{1..1600} >file_a printf "%s\t" R cha 2 987 > file_aa awk '{print}' file_a file_aa > newfile to creat a file in which the header looks like Nt /t n1 /t n2 /t n3 .... ...
2
votes
2answers
134 views

How do I write a Bash script for this scenario?

I have these files in the directory home/acs. TBBN027162G_38d8-2f08-0c40 TBBN027605G_38d8-2f08-1518 TBBN027941G_38d8-2f08-0d1c TBBN027923G_38d8-2f08-35e4 I want to read TBBN027162G as service_id ...
6
votes
5answers
378 views

How do I delete everything after second occurrence of quotes using the command line?

I have this store in a variable sCellEventTrap-03-28 TRAP-TYPE -- CAC Code: 00 ENTERPRISE compaq VARIABLES { scellNameDateTime, scellSWComponent, ...
3
votes
2answers
81 views

Are there any Linux programs that can easily write and edit interlinear text?

Specifically, I'd like to have one line have the English, while another has the Hebrew/Aramaic/Greek/Latin/etc, and possibly (if any program has this capacity) an additional line/lines for extra ...
3
votes
6answers
577 views

Concatenate two files and separate them with a newline

I have two files: k.txt: 3 5 7 9 19 20 h.txt: 000010 100001 111001 if I just use cat, there is no newline. I need a command which would provide a file which looks like this: 3 5 7 9 19 20 ...
5
votes
6answers
531 views

Grep beginning of line

I have a file with the following contents: (((jfojfojeojfow // hellow_rld (((jfojfojeojfow // hellow_rld How can I extract every line that starts with a parenthesis?
1
vote
3answers
122 views

retain white spaces in fields when using awk

I am using nawk on a pipe delimited file to print fields as index and key where some of the fields contain white space, when there is no white space everything works normal, but in case of white ...
4
votes
5answers
575 views

How do I remove lines of a file which contain a specific string?

How do I remove lines of a file (hosts) which contain "adf.ly" string?
3
votes
3answers
284 views

How can I cut email addresses with sed?

I have the following emails.txt with: tsar@gmail.com c2m_@hotmail.com.es c72@hotmail.com.es.com;es m7_@hotmail.es.com cm_@hotmail.com @pepito.com And a sed command to get sed -n -r ...
3
votes
2answers
272 views

How do I remove blank lines from files?

I have a file (hosts) with some lines without content, how do I remove that lines without content?
1
vote
4answers
29 views

How do I remove comments of a file?

I have an file (hosts.txt) and many lines in that file are comments. How do I remove that comments?
5
votes
4answers
104 views

Specific edits to a text file (awk?)

I have a file that looks like TITLE 1.000000000000000 10.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 10.0000000000000000 0.0000000000000000 ...
1
vote
3answers
90 views

removing “_” from a very large csv file

I have a large csv file (120GB) that looks like this: "JE",865438083645,2012-12-05T23:07:36.000Z,24,"NQ",142,"658_55525",475035504705 ...
2
votes
6answers
263 views

How can I extract text between a pair of the same character?

Input: blahŤfoobar1Ťblah Desired output: foobar1 I want to get the text between two "Ť" characters. Assume there will always be either 0 or 2 "Ť" characters, to make things easier. I tried the ...
1
vote
3answers
126 views

Remove duplicated from two files and merge the unique ones

I Have two big text files, checksums_1.txt and checksums_2.txt, I want to parse these files and remove duplication between them and merge the unique lines in one file. Each file have the following ...
2
votes
1answer
66 views

How to enter newline in table cell where the text orientation is vertical (Libreoffice Writer)?

In Libreoffice Writer (Version: 4.3.7.2), how do I enter a newline in a table cell where the text orientation is vertical? My operating system is Ubuntu 14.04.2 LTS Trusty. I have a table cell ...
6
votes
5answers
611 views

How to replace all strings in a file that begin with some prefix

Example: 1:20 2:25 3:0.432 2:-17 10:12 I want to replace all strings that begin with 2: to 2:0. Output: 1:20 2:0 3:0.432 2:0 10:12
5
votes
8answers
711 views

How can I capitalize letters before a certain character? (^)

I would like to convert this: foo^bar ba^rfoo oofrab raboof^ To this: FOObar BArfoo oofrab RABOOF Anything before the "^" (or another special character if it makes it easier) gets capitalized ...
6
votes
8answers
378 views

Access individual lines of a text file and create separate text file with that name

I have two text files (say text1.txt and text 2.txt) both with same number of lines. Ex. text1.txt contains 4 entries 0127H 0132H 0982H 1772H text2.txt contains 4 entries stev mary beautiful ugly ...
1
vote
3answers
70 views

Edit text iteratively within a file using commands

I am a new Ubuntu user. Please help me in solving the following problem: My input text file is -0.716425 -12.8939 -3.3341 -7.38497 -2.62709 3.00437 -6.69861 -13.8853 -5.81095 -7.37465 ...
2
votes
2answers
167 views

How to delete all lines before and after the specific strings in the file?

I have played with Powergrep and regular expressions but I don't know how to do that: I have the text file (source code of webpage) and I want to delete all text (a lot of lines) before the specific ...
3
votes
4answers
266 views

Replace string with multiline file content

I need to replace string SALT in a file with content of another file. Problem is that the input file has multilines. I tried something like this in my bash script: SALT=`cat salt.txt`; sed ...
0
votes
2answers
43 views

How do you create a process list ''file'' like process.txt on windows?

I would really like to know whether there is something similar to process.txt on ubuntu. You know, an overview of all of your processes as a text-file in order to E-Mail it to others or load it on an ...
3
votes
3answers
216 views

How to label occurences of text?

I would like to convert blue blue red green to: color.1=blue color.2=blue color.3=red color.4=green Any leads on how to tackle this? sed, awk, etc.?
1
vote
1answer
65 views

Command-line perl regex replacement: replacement string contains utf8

Say you have a file named test.txt with the following lines: ಕದಂ.ಬ कदम्ब. Then, suppose you want to replace each dot following a devanagarI unicode character (ie in कदम्ब) with a ।. Then, you might ...
2
votes
1answer
256 views

copy several lines from one file to another

I would like to use grep in order to copy from one file to another all lines that are between lines /protein_id= untill the end of the protein sequence shown. For example, from this input: CDS ...
1
vote
1answer
96 views

Find and replace regular expression (matching unicode character class Devanagari) in multiple files

Say you have a file named test.txt with the following lines: ಕದಂಬ कदम्ब Then, suppose you want to replace each devanagarI unicode character (ie in कदम्ब) with a D. Then, you might think that the ...