Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

1
vote
3answers
35 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
137 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
57 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. ...
3
votes
2answers
59 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; }' ...
0
votes
1answer
27 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
55 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 ...
7
votes
4answers
356 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
38 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 ...
-1
votes
0answers
26 views

Count how many times a word occurs in a txt file with awk

Basically i'm trying to count all instances of certain words that occur in a text file then printing the result. It has to be in done using awk. Im not really sure where to start. Any suggestions?
0
votes
1answer
24 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
votes
0answers
23 views

target a specific part of code and change it

I have the following html code <td style="color:#8C8C8C;font-size:10px;font-family:Arial,'Helvetica';text-align:center; padding:0 15px 0 15px;">Keep ensured your hat is fine.<br /> If ...
1
vote
2answers
42 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
28 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
87 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
23 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
48 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
193 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
46 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
37 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
37 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
90 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
30 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
43 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
61 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
41 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
42 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
61 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 ...
-4
votes
0answers
34 views

copy to XML file

echo "Please Insert file name with format eg: test.xml" read input_variable cat $input_variable > test.txt sed -i "s/$word\b/$replace/g" "test.txt" cat test.txt > $input_variable I want to ...
0
votes
1answer
27 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
29 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
26 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
41 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
77 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
100 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
85 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
91 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
48 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
92 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
53 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
34 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
41 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
27 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
40 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
52 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 ...
-1
votes
1answer
32 views

How to add a line number follow by a tab to a text file

I tried using nl -ba -s '\t' full_media > full_media2 But it really did not add the tab, but it added actually the "\t" text after the line number. The file im editing is a CSV file and here by ...
1
vote
1answer
101 views

grep (/sed/awk) month range

I've looked around for solutions to this, but it's sort of difficult to search for the solution to such a specific problem (lot of words to put in Google). So, I have a file with data that looks like ...
-1
votes
1answer
36 views

Script to `grep` a file with variable [duplicate]

while read wholeline do echo ${wholeline} --outputs John Jones #grab all the lines that begin with these values #grep '^John Jones' workfile2 --works, prints contents of workfile2 where the ...
0
votes
2answers
51 views

How to run a script to get certain contents of a file

So say a file has the login data for a bunch of users: bobby activityname 2014-05-12(bobbymiller@gmail.com) bill activityname 2014-06-12(bobbymiller@gmail.com) bobby activityname ...
0
votes
0answers
39 views

Bash - Convert escape character colored text to BBCode

I want to convert a terminal escape-character colored text file to BBCode colored text. For this i've created an Android logfile with logcat -Cd > /sdcard/logcat.txt. The -C switch adds the color ...
2
votes
4answers
70 views

Substitute all occurrences of pattern with first matched group

I have to go from this: text match$something_here and match$xxx blablabla text match$something_else_here and match$xxx blablabla ... to this: text match$something_here and match$something_here ...