Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

0
votes
3answers
58 views

How can I capture the common characters between two strings

I'm looking to compare two strings and capture the common part e.g. FILE0000010985.LOG FILE0000010999.LOG FILE0000011000.LOG If I compare 1 to 2, I want the output to be ...
0
votes
3answers
45 views

I want to condense a list of ranges (from-to)

I have data involving codes assigned to ranges in the form of From To Code 0 5 A 5 10 A 10 15 A 15 20 B 20 25 B 25 30 A 30 35 A 35 ...
2
votes
4answers
42 views

grep and print how many times my pattern in file 1 is present in file2

I have a file1 (list of my pattern) like this: file1 Fatty_acid_degradation Aminobenzoate_degradation Amino_sugar_and_nucleotide_sugar_metabolism Amoebiasis and I have a file2 (list of all the ...
1
vote
1answer
40 views

Specify the type of field to modify in a file

I have a list of clients, "code", "name", "location", "etc" and I want to make a function that asks the employee to give the client's code and then the field he/she wants to change. For example, ...
1
vote
1answer
70 views

Shell script runs diffrently based on working directory.

I have a script which runs differently based on current working directory. Basically it processes an .ini file and takes parameters from it and runs mysql backup. Script is running as root user. ...
2
votes
3answers
106 views

Find the number FN with awk

I have one document, and this document has several columns, like this: ,Flag2,,Flag4,Flag5,,,,,Flag10,Flag11,Flag12,Flag13 If I use awk to know the total number of fields, knowing the separator ...
1
vote
1answer
46 views

delete non important characters from command output

the version command in my Linux machines display the following output version Red.Hat.OS. release..........5.5 APP.Release.............4.2.0.0-02 how to remove the middle "." dot character ...
2
votes
2answers
125 views

How do I insert new columns into a .csv file?

Example Data: "Monday","12345","Friday" In the above file, I want to add a new column in between 12345 and Friday. How can I do that ?
1
vote
3answers
46 views

Select and remove lines matching a pattern from a file

grep -Eri "drucken" app/views app/views/meths/_form.html.erb: <li class="hidden-phone"><a onclick="javascript: print();" class="">Methode ...
2
votes
3answers
189 views

How to extract only a part of one line?

I want to extract the essid in a dump file from airodump-ng using grep. The part where I want to extract looks like this: <SSID first-time="Wed Feb 25 07:06:57 2015" last-time="Wed Feb 25 ...
1
vote
0answers
77 views

Sed regex printing into a file.txt

I'm connected to a MQTT stream, and I filter out the data by entering : mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}" into the Ubuntu terminal. ...
4
votes
2answers
79 views

Use lines in a file to produce string and file name

I have a file, foo.txt, that has a folder name on each line: folder_1 folder_2 folder_3 And I'd like to do something like this: cat foo.txt | xargs -I {} echo 'function {}() { return stuff; }' ...
5
votes
2answers
146 views

Transpose a file, and replace missing values

I have Readings for Names, from Machines and sometimes these readings are replicated. Where a reading was not found, it is left as blank. Name Instrument Rep R1 R2 R3 N1 I1 1 1 2 3 N2 I1 1 1 3 4 ...
0
votes
1answer
39 views

looping through a file on 2 lines in shell

I have a file which looks like this: >a TCCACTCCACGC >b ACCTCCAG I want to loop through the file in such a way that it takes into account 2 lines at a time i.e >a and its sequence and then ...
4
votes
2answers
69 views

How can set a row as column in unix [duplicate]

How can I set a row as column in Unix. Example: name : Keshav sub : C++ branch: cse DOB :22/09/1990 company:NONE name : Vijay sub : Java branch: cse DOB :22/09/1985 company:NONE I want output ...
9
votes
4answers
526 views

How to remove duplicate characters?

If I am having a line as: Thhiisss iisss mmyyy nameeee I want to print this as: This is my name What is the unix command for this?
1
vote
1answer
190 views

Print lines between two patterns matching a condition in awk

How can I print lines between two patterns which meet a certain condition? For instance for an input file partially containing the following: Time %MEM %CPU %SWAP 00:05:02 7.3 ...
0
votes
1answer
31 views

Printing out range of a pattern with awk

Im trying to print out a section of a txt file using awk. Basically I want to print out the paragraph in the a txt file that begins with certain words all up to a blank line.Here's what I have so far: ...
1
vote
2answers
102 views

print the output of 2 commands in 1 file on the same line

Thanks for looking at this. I have a possible simple question, but I wasn't able to find any help so far on the internet. I have a script that has mainly 2 commands that process output. But both ...
1
vote
2answers
86 views

how to remove a multilined string/block of text pattern from a file? [duplicate]

I have a text file that has a multiple lined string of text I'd like to scan the file for and remove all instances that it finds of that multilined and potentially sometimes duplicate string. example ...
1
vote
2answers
160 views

How can I remove a carriage return, add a time stamp and ignore some data from a live MQTT feed

I type mosquitto_sub -d -t +/# from the Ubuntu terminal to access the MQTT stream. Real output from the live MQTT stream is this: Sending PINGREQ Received PINGRESP Sending PINGREQ Received PINGRESP ...
0
votes
1answer
28 views

how to change several piece of html code

I have several chunks of html code ,see below, in a html page that I need to change Assurez-vous de bien recevoir tous nos messages en ajoutant bebeco@concretisezvosprojets.com à votre carnet ...
1
vote
1answer
116 views

How to extract certain data from an MQTT stream

I type mosquitto_sub -d -t +/# from the Ubuntu terminal to access the MQTT stream. However I would like to see only a specific set of data from the MQTT stream. I've added | grep -v PING so ...
2
votes
5answers
528 views

cut for key-value pairs

I am looking for an easy way to cut key-value pairs (where the key is unique and specified) from text, much like how cut can be used to cut a specified column in a CSV file. The keys I'm looking for ...
3
votes
3answers
49 views

sed command and formatting one line help

I need help turning these headers: '>>tr|G1PEZ0|G1PEZ0_MYOLU Uncharacterized protein (Fragment) OS=Myotis lucifugus GN=SNCG PE=4 SV=1 into just this: '>G1PEZ0_MYOLU I've given up. I ...
0
votes
2answers
49 views

How to weave the words of a string into a block of strings in vim?

Given a string and a block of strings e.g. String: Use three words. Block: This is the first string of another block of strings. This is the second string of another block of strings. This is the ...
0
votes
1answer
49 views

Parsing a txt file according to two different tags

I need to parse a txt file like below. The part that needs to be parsed starts with "SASN2010Aber.CallEventRecord.egsnPDPRecord" and text is between two parenthesis {...}. The key text length is not ...
1
vote
2answers
114 views

Last line is wrong when splitting a file with awk

I have a data file main.txt that looks like this 20130826,aaaaaaaaaaaaaa,bbbbbbb 20130826,sdfasdfasdfas,sdfasdfasd 20130826,dfasdfas,asdf2323 ... 20130827,sfasdfasdfasd,sdfasdfwea I used the ...
1
vote
1answer
48 views

Replace case-insensitive string in all folder files

I'm trying to replace a string with another in all files in dir. Trying to use this command sed 's/foo/bar/' * But it replaces foo and not fOo or Foo and others. how to find "foo" ...
1
vote
1answer
60 views

Single record of a file getting splitted over multiple lines

We are using flat text files to store in teradata table after transformations from Informatica. The file contains 14 fields (~ separated). But as the records are getting scattered over multiple lines ...
2
votes
2answers
92 views

How to extract the positive numbers in the first column from an output as in the question?

I am running Ubuntu 14.04.1 LTS 64-bit with Bash 4.3.11(1)-release I have a program called harminv producing output as follows: $ h5totxt hsli0.126.h5 | harminv -vt 0.1 -w 2-3 -a 0.9 -f 200 # ...
2
votes
2answers
46 views

How do I extract the content of quoted strings from a file

have a file which looks like this: anm="12S123S" family="" type="Std" product="" name="nand" allow="yes" anm="12321 S=" family="" type="Std" product="" name="dan" need="No" anm="SWED" family="" ...
1
vote
1answer
67 views

print second column in transposed row

I have a space separated table (as in this example): A 101 B 92 102 C 83 93 103 D 74 84 94 104 ︙ I would like to obtain this: sample A with the associated value and all the second column ...
2
votes
5answers
81 views

Add every two consecutive lines in a column and divide it with the former and Print

I have a input file of almost 2000 lines. I have to do a calculation and print it in the third column. Example of what I have to do with the Input File: n ID1_1 n/(n+k) k ID1_2 Input File: 10 ...
0
votes
1answer
122 views

Loop for's result in a variable for sql query

I have this part of my script for i in `cat ${RELLIST}` do for mr in `cat ${i}/DBA/install.list` do grep -i "'dba_" ${i}/DBA/sql/${mr}/*.tab 2> /dev/null | sed 's/^.*://' #grep -i ...
1
vote
1answer
37 views

What does >… mean in vim and how to substitute a single whitespace for it?

I know that when :set list is used whitespace is shown as .. But what does it mean when a whitespace symbol is preceded by >, e.g. >., >.., or >...? And how do I remove it and leave only ...
1
vote
2answers
47 views

How do I transform array output sorted in lexicographic order to numeric order

I have a text file that consists of data in this form: int array[0] int array[1001] int array[1002] int array[1003] int array[2] int array[2001] int array[2002] ... In other words, the numbers ...
0
votes
3answers
46 views

Split the file comparing two fields in the files

Have two files which need to compare the first two columns. Sample input file1: |CID|SID|order|orderdate|confirmdate |151244127820|7177638911583| 2|2015-02-04 07:14:44|2015-02-04 07:15:32 ...
4
votes
3answers
141 views

How can I find and replace only if a match forms a whole word?

My script is: n="y" while [ "{n}" = "y" ] if [ $n == "n" ]; then break; fi echo "n is $n" do read -p "Enter the word to find = " word read -p "Enter word to replace = " replace ...
1
vote
2answers
407 views

extract blocks of text from xml file

I have a file with these contents: <People> <Person> <Name>Joe Blogs</Name> <Address>55 Oxford St</Address> ...lots of other properties ...
2
votes
2answers
139 views

Delete rows from a simplified CSV where some columns matching specific pattern

I have the following simplified CSV file (no separators or newlines embedded in fields): ...
1
vote
3answers
553 views

Compare two .csv files

I have two files: 'file1' has employee ID numbers. 'file2' has the complete database of the employees. Here is what they look like: file1 123123 222333 file2 111222 Jones Sally 111333 Johnson ...
0
votes
3answers
89 views

How can I output sample rows from a .csv?

I'm doing a lot of data merge printing and would like to be able to output, say, 10 samples from a large database. My goal would be to extract the 10 rows spread evenly from the supplied .csv ...
2
votes
6answers
149 views

Scripting to split a single CSV row into multiple

I need a script that can take a CSV file with that has a column of semicolon-delimited attributes, and break it into multiple rows to normalize that multi-valued attribute? Here is the scenario: ...
1
vote
3answers
80 views

Filter csv file based on extended column values

I have the following csv file: ID,PDBID,FirstResidue,SecondResidue,ThirdResidue,FourthResidue,Pattern RZ_AUTO_1,4tov,1404,1405,1518,1519,CG/AA Canonical ribose-zipper ...
2
votes
2answers
41 views

how to print the closest column when looking for a specific strings

I have a file with around 12 000 lines. ...
0
votes
2answers
54 views

How to add a column if line contains string?

If I have a tab-delimited file containing the following lines: Sample1-Baboon 1 2 3 4 Sample2-Human 1 2 3 4 Sample3-Human 1 2 3 4 Sample4-Baboon 1 2 3 4 How can I add a new column ...
0
votes
1answer
31 views

Filter by column value and write to file

I have a table like this: BB1520_v1.0_0103 exon 3329 3601 BB1520_v1.0_0103 exon 3650 4040 BB1520_v1.0_0089 exon 1 862 BB1520_v1.0_0089 exon 1312 ...
1
vote
1answer
61 views

sed regex not working for hidden characters

I have a list that has for some reason got some non alphanumeric characters appended to the end. I would have thought it would be a simple case of running : sed 's/[^A-Za-z0-9]$//' To replace ...
0
votes
5answers
93 views

How to Read string from file and compare to each line of second file

I'm making the post OS installation script that will include the Hardening section . And in this hardening section it will read the Kernel parameters from file A and compare to file /etc/sysctl.conf ...