Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

-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
50 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
57 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
42 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
31 views

Removing unwanted lines from the file [on hold]

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
24 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
228 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
4answers
115 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
53 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
31 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
31 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
2answers
43 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
85 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
63 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
137 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
3answers
30 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
42 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
78 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
43 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
45 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
50 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
44 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
178 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
41 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
55 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
204 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
33 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
83 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 ...
5
votes
6answers
299 views

split file into two parts, at a pattern

How to split a large file into two parts, at a pattern? Given an example file.txt: ABC EFG XYZ HIJ KNL I want to split this file at XYZ such that file1 contains lines up-to XYZ and rest of the ...
0
votes
3answers
68 views

Reorder lines in each 3-line record

I have a file which contains lots of records in following manner. Name Address Phone This is the sequence for each record in that file. Now, I want to copy this file to other file with changed ...
2
votes
2answers
87 views

Extract substrings from each line. These substrings are in comma separated, “name=value” format

I have lines in a file that are comma separated. There are no column headers, it's mostly comma separated 'name=value' pairs. Here is some test data: ...
2
votes
3answers
49 views

Reformat date string

I am trying to figure out how to reformat a file full of wrongly formatted dates. The source looks like this: {"_id":"","timestamp":"Mon Apr 20 08:30:55 +0000 2015"} {"_id":"","timestamp":"Mon Apr 20 ...
0
votes
1answer
55 views

How can I regex specific links from rss content in yahoo pipes?

From a RSS content I'd like to remove everything except specified href links Example: <div class='text'> <div class="center"> <b><a rel="nofollow" target="_blank" ...
-1
votes
2answers
52 views

How to split output lines into multiple lines (only lines not files)? [duplicate]

My requirement is display output lines into mutliple lines My code is: #!/bin/bash dir="$1" echo -n "file size:" du="$(du $dir -hab | sort -n -r | tail -1)" printf "%s\n" "echo "$du"" It's ...
1
vote
2answers
73 views

How to check each line within a pipe delimited file to be same of different

I have a pipe-delimited file which can have millions of records. What I want to do is sort the file and remove if there are any duplicate lines there. Then I need to check the first 32 columns and ...
1
vote
2answers
64 views

Search and replace multiple strings in a script using vim(search and replace) commands without sed?

A script that creates a file for weather precipitation is, #!/bin/ksh x=10 b=snow c=rain d=snow e=hail echo "$x,$b,$c,$d,$e" > weatherfile exit 0 given 3,8s/snow/dry/g For the search and ...
1
vote
2answers
37 views

Copy line in file if we know the pattern [closed]

We have a file which has 10 lines, and I know that some line has text QWERTY. How can I manipulate the file so that it copies that line and paste it. The output is similar to that yy and p command ...
0
votes
1answer
55 views

Help in manipulating a test file

I have a file look like aaa/bbb/ccc.bbb aaa/bbb/ddd.bbb aaa/eee/fff.eee aaa/eee/ggg.eee I would like to skip lines ending similarly (where ending is defined by the extension, e.g. .bbb & .bbb) ...
0
votes
3answers
56 views

Removing line-breaks, whitespaces and tabs from every file

Say I have a folder with 10K text files. I would like to remove every space, TAB and linebreak from each file. How can I do this efficiently?
1
vote
2answers
69 views

AWK script to compare content of 2 files

I need experts help in resolving my following problem ... I have 2 files .. file1: abc|123|check def|456|map ijk|789|globe lmn|101112|equator file2: check map equator globe AWK function ...
2
votes
3answers
98 views

add space 5 times at the beginning of each line in a text file

I am looking for a command line or bash script that would add space 5 times before the beginning of each line in a file. for example: abc after adding spaces 5 times abc