Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

1
vote
2answers
42 views

sed remove Space

i have list name.txt with this string : Los Angeles, CA us1.vpn.goldenfrog.com Washington, DC us2.vpn.goldenfrog.com Austin, TX us3.vpn.goldenfrog.com Miami, FL us4.vpn.goldenfrog.com New York ...
3
votes
2answers
77 views

Find each line matching a pattern but print only the line above it

I need to find a string and need to print the line above it. case1: The same line won't have the more than one matching pattern ie) consider a file containing $cat > para returns between the ...
1
vote
2answers
38 views

I would like join two csv files

I would like join two csv files: file1: 19/02/2016 22:00;16.70 19/02/2016 22:30;16.80 19/02/2016 23:00;16.80 19/02/2016 23:30;16.70 file2: 19/02/2016 22:00;39.50 19/02/2016 22:30;41.00 19/02/2016 ...
2
votes
3answers
47 views

Copy column with file name as column header

I wanted to organize my dataset by copying the a column from a number of text file and append the file name in the first row of the new files. Here is sample of my data file1 a a b b 1 2 ...
1
vote
2answers
39 views

what command would I use to see all lines from a file starting with a line that I find with grep

what command would I use to see all lines from a file starting with a line that I find with grep so I imagine something like a tail, but beginning from a line that I identify with a grep. For ...
4
votes
3answers
372 views

How to replace a multi line code with sed?

I have a large file which has special characters in it. There is a multi line code there, that I want to replace with sed. This: text = "\ ------ ...
-2
votes
1answer
18 views

Remove some elements of a string and replace with others

How can I convert this : RS.PK.03.01.4200.03.014.01 to man03140101? What needs to be done? Text before 5th "." has to be removed : RS.PK.03.01.4200. The remaining text should be converted ...
-1
votes
3answers
32 views

How to delete the first few lines of data and a specific matching numeric number until the very end of data

51 0 0 5 0 0.0 0.0 0 1 2 3 4 5 6 7 8 1, 2 0.998 0.567 3, 2 Rs12345 0.7 0.2 3, 2 Rs31256 0.56 0.311 3, 2 Rs25691 0 0 012.1313010310 0.1213212 0.2121331321 0.0121654564 0.254564564 ...
0
votes
6answers
76 views

Merge multiple lines in same file based on column 1

I'm still learning programming and I've tried many things but just cannot get the correct format. I have a tab delimited file with 17 columns and many (around 50.000) rows. The file is already sorted ...
1
vote
2answers
47 views

Split file into multiple files based on pattern [duplicate]

I have a large file that's a couple hundred lines long. This file is partitioned into many parts by a specific identifier, lets say 'ABC'. This line 'ABC' appears 6 times so I want 6 output files. I'm ...
3
votes
1answer
46 views

Replacing a & in XML correctly?

I want to replace a '&' with &amp; Except the following occurance of XML special characters. " &quot; ' &apos; < &lt; > &gt; & &amp; I tried the ...
0
votes
1answer
21 views

extract block of words from specific delimiter

I have a block of words like this, on a single line: Id item: VALUE nom: VALUE type: VALUE path: VALUE Id item: VALUE nom: VALUE type: VALUE path: VALUE Id item: VALUE nom: VALUE type: VALUE path: ...
6
votes
2answers
161 views

for loop over input lines

I have a file with a lot of lines like this /item/pubDate=Sun, 23 Feb 2014 00:55:04 +010 If I execute this echo "/item/pubDate=Sun, 23 Feb 2014 00:55:04 +010" | grep -Po "(?<=\=).*" Sun, 23 ...
-1
votes
1answer
19 views

retain unique values in txt file with counts

I have a text file with a single word in each line. I would like to convert this to a text file that only has each word appearing once, and also give the number of times that word appeared in the ...
1
vote
2answers
102 views

Grep line after/before -A/-B substitution in AIX

I'm using AIX 6.1 which isn't supporting in -B and -A flags: grep: Not a recognized flag: B Lets say I want to run: cat file | grep -E -B4 'Directory entry type.*Indirect' | grep "Database name" | ...
1
vote
3answers
52 views

Combining text across contiguous lines keyed alike?

I have an input CSV file that looks like this: john,Hello my name john,is John katie,Whereas my katie,name is Katie bob,And I am Bob. The file is ordered such that names (in the first column) are ...
2
votes
2answers
68 views

Script to modify XML config file

I'm trying to automate an installation process with a script. Part of the process is finding certain sections of the XML config file (seen below), and changing certain parameters from false to true or ...
1
vote
1answer
24 views

If #head versionnumber.txt < #head latestversionnumber.txt then: do this

I'm working on automating an update service. I created two text files that just contain the version number. versionnumber.txt: 3861 latestversionnumber.txt: 4002 How can I compare these two ...
3
votes
4answers
78 views

Find duplicates by column in a file

I have an input file containing file paths and their md5sum, separated by semicolons and sorted by md5 hashes : /media/LaCie/Images/recup2/recup_dir.1/f1295328.jpg;0080ececd3da8533f5d11e449cf73287 ...
1
vote
2answers
23 views

Strip certain objects out of a flat file database

I have a flat file database and I need to strip certain objects from it. There are numerous blocks in the file but I am interested in 2 objects in the OBJECT NickCore block. Example below: OBJECT ...
3
votes
1answer
31 views

Comparing ping times in FreeBSD sh

How can I strip the time from a ping return? For example: 64 bytes from 10.3.0.1: icmp_seq=0 ttl=63 time=2.610 ms I want to grab the value after time= and pass it to a test like: if time>=50.0; ...
0
votes
1answer
30 views

remove the last character of the line if it is a

I have a file of the form bulandshahara b u l a n d sh a h a r a caandapura c aa n d a p u r a I have to remove the "occurrence of a space followed by a" if this pattern appears at the last of ...
0
votes
2answers
24 views

Replace first occurrence of space with a TAB

I have a file of the form: acaneeraa a c a n ee r a acaneeraa a c a n ee r aa acaneeraa a c n ee r aa achaldaa a c a l d aa achaldaa a ch a l d aa I have to replace the first occurrence of a space ...
0
votes
4answers
57 views

Grep for a string and then echo a string back from a record

I have the following record: MiraServ.log.10:2016/02/07 15:25:13 3 All stations busy!! MiraServ.log.10:2016/02/07 15:25:13 1 TranHasError (3627,-2) ...
0
votes
1answer
55 views

Sed command for performance improvement or tr command for the same

I have a command to replace the non printable characters and single quotes from a file but its taking more time to execute as I am replacing these characters for multiple files and the files size is ...
0
votes
1answer
23 views

Split a large file into unique files [duplicate]

I have huge file 100M, that has the text (few lines below,) stack of lines are unique scaffold1_, scaffold2_ and on. I would like to have a new file that is specific to each scaffold.1...txt tried ...
0
votes
3answers
45 views

Replace composed unicode characters

I have a file with precomposed unicode characters. Here's wikipedia page about it. I have got a word like "Åström", but accents aren't in the alphabet of this language. I want to get rid of them, ...
3
votes
4answers
68 views

display lines with not more than 4 words in the second column

I have a symbol table of the form M07UP49A0870I422.wav <s> haraa keelaa <bn> </s> M07UP49A0870I423.wav <s> <horn> jau <babble> </s> ...
0
votes
1answer
30 views

Print lines not containing a Tab

I have a text file (around 15000 lines) that is supposed to contain two fields separated by a Tab in each line. Is there a way to display the lines that do not contain a Tab separating the two ...
0
votes
1answer
41 views

Convert a column of epochs into a time column starting from 0

What I have Hi, imagine a lot of this files, where first column is epoch, and the other(s) column(s) are some data: 1000333,34,1 1001456,56,0 1005356,34,2 What I need I need to transform them ...
3
votes
2answers
151 views

Is there a way I can grep recursively over all the files in the current directory to find a pattern and then print it in order of high to low?

So so far, the code looks like this: grep -rc 'Author' $1 It prints out all the files in the directory, which is taken as an argument. However, how would I sort the output (for example): - ...
0
votes
1answer
22 views

How do I use sed to change },{“Foo” to }\n{“Foo”?

I have a 55MB JSON file with a huge number of objects that are separated by },{. I would like to have one object per line and get rid of the comma. For one thing, I'd like to be able to look at the ...
1
vote
1answer
59 views

How to subtract rows from first row using awk?

My data file looks like: 10 -0.314690785295 20 -0.251967909317 30 -0.215271387106 40 -0.189228416217 The desired output is: 10 -0.0627229 20 -0.0994193 30 -0.1254623 I am really new in bash, so ...
1
vote
3answers
44 views

Joining two parts together to make a single script

I'm trying to create a script to do the following: extract the magnet link from a lynx bookmark and then use it as part of a curl command. like this: curl ...
0
votes
4answers
41 views

Multi-column format to 2 column format

I have file like this: 1 a,b,c 2 z 3 d,f and would like to have this format: 1 a 1 b 1 c 2 z 3 d 3 f
4
votes
2answers
100 views

Bash script to extract some information from Ebay HTML pages

I would like to filter the output of a search on ebay which I've exported to a text file. There are a number of results in the search but I've included just one example at the bottom of this post as ...
0
votes
4answers
47 views

Print only unique lines from file not the duplicates

I have a sorted words list, line by line file like so: apple apple grapes lime orange orange pear pear peach strawberry strawberry I only want to print out unique lines and drop duplicates: grapes ...
0
votes
1answer
85 views

Read columns from file into separate variables

I need to read the following input into separate columns as variables? input.txt b73_chr10 w22_chr9 w22_chr7 w22_chr10 w22_chr8 w22_chr6 I have written the following command;but I guess it ...
1
vote
1answer
53 views

How to remove date format

I have the following content in the file. I would like to remove dates and the underlines from the file using sed. let me know if this would be possible to do with grep either. Can someone assist on ...
0
votes
2answers
30 views

Joining certain lines of text together before modifying them

I have a cricket commentary like - 0.3 Richardson to RG Sharma, 2 runs, gentle, non-swinging length ball on off, Rohit seeks to pick it up. Hit high on the bat and spooned over the returning Mitch ...
5
votes
1answer
122 views

Reuse rsync --dry-run output

I usually do rsync -n before doing an actual rsync. The thing is, how could I automate the second run to reuse exactly the list generated with --dry-run? I mean, if I run rsync -n then I get a ...
4
votes
3answers
198 views

How do you extract a whole word containing substring?

If I have a file that looks like this: example.png example.jpg example2.jpg example2.png example.swf example2.swf example3.jpg example4.jpg example3.png example3.swf and I want to extract the ...
0
votes
3answers
59 views

How to loop through a file and make each line a new regular expression into an awk statement?

FileA.txt: ATGCATGC GGGGGGTT TTTTT AAAA FileB.txt: asdfasdf blah2 ATGCATGC blah3 blah4 delte-me-too GGGGGGTT blah5 blah5 .... I want to compare the each line from FileA.txt and check if it ...
0
votes
0answers
42 views

Create Paragraph Numbers in Roxterm

I have a text file created in Roxterm. I need to number the paragraphs. So, for instance, the first paragraph would be labeled 1 and so on. Is there a command to do this? My text file is called ...
1
vote
3answers
34 views

How do I organize and cut this portion of a directory into a file?

I'm new to unix and I'm not sure how to name my title but my main objective is to copy the contents of a directory and send it to a file. Then cut out the directory location to just have the name. ...
5
votes
2answers
77 views

Search directories for multi line string

Looking for a way to recursively search a repository for all files containing a multi line string and return the file names that contain it. The paragraph is just a header approx 30 lines. So I know ...
2
votes
4answers
92 views

How to move to the “Nth” offset in a file

I'm in need of a command that would help me to the the N th offset in a file. Say this is my file's contents: [root@localhost ~]# cat /file1.txt this is the the first line of many lines and is just a ...
0
votes
0answers
23 views

How to read fields of a text block?

I would like to create sql inserts based on Radius log fields. For example, I have these two types of accounting logs and I'd like to convert each text block to an insert like below: INSERT INTO ...
3
votes
2answers
57 views

How to sort data by the numbers in third column? [duplicate]

If I have a file consisting of data that looks as follows, how would I sort the data based on the numbers in the 3rd column ? The space between the first two columns are NOT tab delimited but some ...
0
votes
3answers
54 views

How can I parse a multi-line command output in bash?

I have a command that outputs the following: Some text here 1,3456: "Descr 1" 2,7891: "Descr 2" 3,0976: "Descr 3" Some other random text here I want to write a bash script that parses ...