Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

0
votes
1answer
21 views

Using Perl to modify specified lines of an ASCII file

Background: (1) I have a data set of scientific notation: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.503832e-05, 1.433673e-05, 2.557402e-05, 3.081098e-05, 4.044465e-05, 2.480817e-05, 2.681778e-05, ...
0
votes
2answers
29 views

sed replace ;“ content with ';”

I have files that contain ;" and I need it replaced with ';" The following sed command does not work: sed -i "s/;"/';"/g" /root/bashy.sh How can I do this? The solution doesn't have to be sed.
-1
votes
1answer
29 views

How to duplicate lines in a text (xpm) file?

I'm having some pixmaps like this (36, to be exact): /* XPM */ static char * hide_active_xpm[] = { "12 14 3 1", " c None", ". c #EDEDED s active_color_2", "+ c #313739 s active_text_color_2", " ...
2
votes
2answers
102 views

how to print field between the double quote

I have the following file conf.txt: perl /home/site/gen.pl "GG - W C1 Test - sai1" "15072" && ssh 13.4.93.103 perl /home/site/gen.pl "GG - W C1 Test - sai2" "15072" && ssh ...
9
votes
9answers
1k views

How can I quickly sum all numbers in a file?

Each line contains text and numbers in one column. I need to calculate the sum of the numbers in each row. How can I do that? Thx example.log contains: time=31sec time=192sec time=18sec time=543sec ...
1
vote
3answers
55 views

Find the complement set of an array?

Following from this question, where I wish to extract 10 random lines from a file, I now wish to also have the remaining 90 lines as a separate file. Since the document has 100 lines, indexing from 1 ...
0
votes
1answer
30 views

Move a range of words to the end of the string

I have the following string: "5 S comment=whatever Unspecific text fruit=apple animal=mouse sky=blue" I need to move to end of the string, all that begin with comment to the word text. The start ...
2
votes
3answers
53 views

Specific column level substitution

If I have a file with columnar entries, is it possible to substitute specific entries from a specific columns only and save changes to the same file?? Example a file abc.txt: SR|FRUITS|COLOR| ...
0
votes
1answer
26 views

.txt File from Mac not converting properly

I have a .txt file from my Mac that when I send it over to my Raspberry Pi running Raspbian and open it in nano it converts weirdly. Example: Text file in Mac OSX: ...
2
votes
2answers
68 views

Delete blank columns

This must be a common problem, but I couldn't find a solution. I have several files which have different sets of columns which are completely blank (for all rows except header) , how can I delete ...
9
votes
5answers
520 views

Combining large amount of files

I have ±10,000 files (res.1 - res.10000) all consisting of one column, and an equal number of rows. What I want is, in essence, simple; merge all files column-wise in a new file final.res. I have ...
1
vote
3answers
41 views

Data extraction from text file

I have a text file in the following format:- $DATA1 SOURCE='HSPICE' VERSION='I-2013.12-SP2-1 32-BIT' .TITLE 'cmos inverter transfer characteristics' index t_r t_f ...
2
votes
4answers
80 views

Extract two values from the output of a command

I'm using the following command in a script to get synthetic wifi info: echo "$( iw dev wlp1s0 link | grep '^\s*SSID:\s' | sed -r 's/^\s*SSID:\s//' ) $( iw dev wlp1s0 link | grep ...
-1
votes
0answers
34 views

How to merge these three task in a single command ( grep | sed | echo)

I am trying something where I parse out from the tags in a file then add back the HTML. I see everyone suggest not to do such with regEx (grep). but here it is grep -m 1 -oP ...
0
votes
4answers
52 views

Remove first 2 columns from first row of a file

I am looking for a command to remove first 2 columns from the first row of a file. The delimiter for the columns is a pipe. Number of columns vary. we just need to blindly remove first 2 columns. ...
0
votes
2answers
63 views

Print text between two patterns not containing a particular word

I wanted to print some text between two patterns which doesn't contain a particular word input text is HEADER asdf asd asd COW assd TAIL sdfsdfs HEADER asdf asd sdfsd DOG sdfsdfsdf TAIL sdfsdfs ...
-1
votes
3answers
48 views

make average row with the same pattern [duplicate]

I have a huge table (10 columns and 6000 rows) and I have to make an average of all the rows only if they have the same pattern in column 3 (ko). My table contains numbers and strings. Here's an ...
-1
votes
2answers
34 views

Removing unwanted lines from the file [closed]

I have eight file's which start with: SEALS-* Each file has a header and data: #Col_1\Col_2\Col_3\col_4 --- header \\\\\\\\\\ --- data If it is a null entry, I need to delete ...
2
votes
1answer
28 views

Adding consecutive characters to duplicate words according to order they appear

So I have files like this but for hundreds of different genes per file. >lcl|accession_cds_proteinaccession [gene=dnaA] [protein=description] [protein_id=accession] [location=location] ...
3
votes
3answers
246 views

Extracting unique piece of text from file with awk, sed or grep

From the output of pactl list sink-inputs, I need to grab the sink input number for VLC. Before that, I'm trying to extract the piece that contains the output for only VLC. All the methods that I ...
4
votes
3answers
124 views

Compare two files with four columns

I have two csv files with some log information. I need to compare line to line the field1 (file1) with field2 (file2) with a range of 1 minute (-00:00:01 < time < 00:00:01) and the field5 ...
1
vote
2answers
55 views

How to do operation on individual matches in a full line

I have a Verilog line like this: if (i2_0&!(i2_1)) (posedge i0_0 => (o:1'b1))=(0, 0); How can I convert it to a line like: if (i2_0 == 1'b1 & i2_1 == 1'b0) (posedge i0_0 => (o:1'b1))=(0, 0); ...
1
vote
2answers
32 views

Extract some columns from grep output

I've run the command grep -a --binary-file=text "DLDM" /home/path/ldm.log-$1* | grep -a "$line" and the output is something like this :- /home/path/ldm.log2015:"unix","20150518 ...
2
votes
4answers
36 views

Join multiple files with two blank lines?

I'm trying to join Markdown files with two newlines between each file. I've tried using the following command: paste -sd '\n\n' file1.md file2.md This joins the files with a newline, but not two ...
0
votes
1answer
50 views

Delete customers domain extension only (in .csv file)

I have a list of my customers emails and want to remove some that end in .br for example. I would normally do the following command: sed -i '/.br/d' customers.csv But that would also delete a ...
5
votes
2answers
88 views

How to search for text in a file ignoring newlines?

I'd like to search for text that may be split over several lines in a file. A grep that would ignore line breaks and return the matching span of lines. e.g. I would be searching for is an example ...
0
votes
4answers
65 views

Hexadecimal number sequence checker in Linux?

I have a list of hexadecimal number. I would like to check whether they are in sequence or not. That is, they should be consecutive numbers, in increasing order. In other words, there should be an ...
1
vote
3answers
143 views

Find records present in file 1 also in both file 2 and file 3

I have three files file1.txt, file2.txt, file3.txt and they are of same format. I want to select records from file1.txt which are present in both file2.txt and file3.txt based on column 2 and column ...
0
votes
2answers
37 views

How to match and replace an attribute value inside a tag

I am trying to replace the value of following node using sed command. <KeyValue key="EMPTY_SEARCH_CRITERIA" type="String" value="CS_CODE" comment="Configured empty search criteria."/> I am ...
1
vote
2answers
50 views

How to show searched lines as well as number of occurrence of searched string?

I am working on a script which will show all the results and their count on the console based on a particular string . Example: Suppose I searched for a string called "ERROR", I got the below ...
1
vote
3answers
45 views

How to use sed or awk to obtain just a directory

3:ââsdb1 8:17 1 984M 0 part /media/(NAMEOFDRIVEHERE) I want to just have the /media/(NAMEOFDRIVEHERE) location so I can store it in a variable. I've tried some sed commands and have ...
2
votes
1answer
22 views

Perform one of many substitutions in many files at two specific locations

I have about a hundred thousand files, for each file I want to do the following: Between the fifth and sixth character in the file with the following ascii code: 0x1f, a string is present. Now I want ...
3
votes
2answers
79 views

Create a file of pairs from pairs

Say I have the following file: A 1 B 2 CC 33 And I want to create a file containing every combination of two from the previous file, like this: AA 11 AB 12 ACC 133 BA 21 BB 22 BCC 233 CCA 331 CCB ...
0
votes
2answers
18 views

joining a text file in groups of 3 entries

I have a text file like this: X0122 Yellow Car $1200 YK321 Black Car $400 BZ321132 Red Boat $2344 every line is separated by a \n I want to join every 3 elements in a line separated by ;. So, the ...
1
vote
1answer
48 views

Search and sorts error logs based on a particular string

How to search through all the errors.zip as well as from errors.log files filter by "Error" string and sort by date? What about totals of errors? requirement : here are 3 components are installed ...
3
votes
1answer
48 views

Counting number of entries in column 2 where column 1 is similar

I am trying to count the number of entries in column 2 for the same column1 and also number of times the first entry in column2 for similar column1 occur. For example my input TSV file is: C1 NC01 ...
1
vote
0answers
49 views

Grepping multiple instances of a string, with context, from a file

I have a MySQL dump file, which is mostly INSERT statements. I want to grep out instances of the string 'media' from a field in a particular table, with +/- ~10 characters of context. The string might ...
0
votes
2answers
53 views

compare two files and fetch data

I have two files: File A sample >> AT5G46880.1|PACid:19669936 # score bias c-Evalue i-Evalue hmmfrom hmm to alifrom ali to envfrom env to acc --- ------ ----- --------- ...
1
vote
3answers
53 views

Remove special pattern ^M from script which got appended after FTP from windows to Unix

I send a windows file using FTP to an unix system and got appended ^M wherever a new line was intended, and I just want to remove them. One method which I can opt is to run dos2unix command. Can ...
0
votes
3answers
39 views

How to remove a string of characters after and before a specific character?

I have a file with thousands of lines that start with: >Miriam132_38138 Otu32555|1 I need to remove 'Miriam*********' so that each lines begins with: >Otu32555|1 The first string of ...
1
vote
2answers
45 views

Remove string from file name to leave variable?

I have the following list of files: Dorn_Triatomine_A5201_sequence_1_unmappedforTdim_tdim.alleles.tsv Dorn_Triatomine_A5201_sequence_1_unmappedforTdim_tdim.matches.tsv ...
3
votes
4answers
179 views

Replacing new line character with a pipe and a new line character

I am using ksh. I have a file temp.txt with some pipe delimited data. one|two|three|four|five abc|def|pqr|lmn|xyz As clear from example, the record ends with a new line character after the data ...
1
vote
3answers
37 views

How can I swap the order of each two character pair in a string?

I am trying to automate the swapping of characters 1 and 2, 3 and 4, etc, in a an arbitrary-length string of hex characters. Example: A627E39B becomes: 6A723EB9 It seems like this should be ...
2
votes
2answers
42 views

Replace between patterns that start and end in different lines

I have a file with the following format: Whatever1 Whatever2 Whatever3 binaries=( text1 bin2 ohhh3 ) Whatever4 Whatever5 Whatever6 I need to replace whatever inside lines binaries=( and ) with a ...
-5
votes
2answers
58 views

PDF: Using Terminal [closed]

I tried creating a PDF file using terminal . I wrote "vi New.pdf". It created the file. Now that when i trying to double click and open it . It said something like :- The file "New.pdf" could not ...
2
votes
2answers
21 views

Utility which gives line from /proc/id/maps by specific address

Is there an utility that gives me specific line from /proc/id/maps when given specific address from this process? For example when given 0x7fb4a84f6008 it returns: 7fb4a84f6000-7fb4a84fd000 r-xp ...
3
votes
4answers
206 views

How to truncate the second column to given length

Given input of the form XY981743 foobarlkasdf saflkas asfZR!sgfad asdSAD asdsadf SAdfasdf46lk lksad bar foolkasjfdrte how can I truncate only the second column? The delimiter is TAB and the ...
0
votes
3answers
58 views

Printing column value in the next line

My input is in TSV format: C1 r1 r2 r3 C2 r1 r3 Desired output is: C1 r1 r2 r3 C2 r1 r3 So, basically what I want is printing value of column 1 in next line, is it ...
0
votes
1answer
34 views

How can I append and prepend text to single line text output and save it all to one file?

I have a database dumped to sql with create table commands and I need to create a script to apply a given command to some of the objects, such as dropping the table as an example. In the case of ...
4
votes
1answer
87 views

Problem with paste and standard output in linux

I have two files that I am trying to merge, one file is: linux$ cat temp2 linear_0_A_B linear_0_B_A 103027.244444 102714.177778 103464.311111 102876.266667 103687.422222 103072.711111 103533.244444 ...