Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

0
votes
1answer
24 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
20 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
45 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
0answers
32 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
15 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 ...
-1
votes
0answers
26 views

bash shell scripting - How do I check the values stored in a variable? [on hold]

I ran the code below that returns the number of results as 14 which is correct. NUMBERRESULTS=$(curl -s "privateserver:3000/devices/restful_api_device/… jq '.[]|length') echo ...
0
votes
3answers
24 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, ...
2
votes
4answers
45 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
28 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
36 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
128 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
20 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
41 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
35 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
35 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
3
votes
2answers
54 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
38 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
36 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 ...
2
votes
1answer
35 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
26 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 ...
4
votes
1answer
34 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
160 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
0answers
19 views

Most efficient way to replace a line in a text document? [migrated]

I am learning to code in Unix with C. So far I have written the code to find the index of the first byte of the line that I want to replace. The problem is that sometimes, the number of bytes ...
0
votes
3answers
39 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
19 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
30 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
68 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
82 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
13 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 ...
2
votes
2answers
29 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
39 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 ...
1
vote
1answer
35 views

splitting file based on values in specific column

I have a file that I would like to break up into multiple files with uniq values for the first column. For example, here is a file: fileA.txt 1 Cat 1 Dog 1 Frog 2 Boy 2 Girl 3 ...
1
vote
2answers
75 views

Compare columns from two CSVs and merge on matches

I have two CSV files and am trying to merge them based on the first column in the first file matching the third column in the second file. They lines are not sorted. file1.csv: android,1,2 osx,2,5 ...
1
vote
3answers
75 views

Split a file based on required string

I have test file with the below contents: CREATE TABLE XYZ ( ABC INT, CDE CHAR(10), . . . ); Similarly, REPLACE VIEW XYZ ( ABC, CDE, EFG ); CREATE TABLE XYZ_1 ( ABC INT, CDE CHAR(10), . . . ); ...
1
vote
1answer
38 views

Read each line - BASH

my goal is to store each foliated line (actually each rule) into an array. My output: Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT ...
0
votes
2answers
56 views

Automatic Paragraph Numbering [closed]

I have a text file and would like to modify it so that it automatically numbers the paragraphs as seen below. Please make your solutions as simple as possible as I am a novice when it comes to the ...
1
vote
1answer
37 views

cut column range sed/awk/cat

I'd like to cut a certain range of text (i.e. characters 17-63) repeatedly from a *.txt file, which is several thousand lines long. One line looks like this: ...
5
votes
2answers
69 views

How to find one word and sequentially replace it?

I am running AIX 5.3(not by choice, but I cannot change it), and I have a text file: servers.txt Here is an example of the file's contents: apple port1 username password IPAddress TCP banana port2 ...
1
vote
1answer
37 views

replace unix path inside a file

I have a sql file of a wordpress database. I am moving to another server which the document root is different. The old document root was /home/saeid/public_html The new document root is ...
1
vote
1answer
39 views

Test length of string in file

I am not sure if I am using my argument correctly. I would like to pass in a argument which is a text file containing a string. When I run this script, it always enters the if statement even when the ...
3
votes
3answers
136 views

Retrieving lines from a file depending on other lines

Imagine the following file structure: foo.bar.1 blabla moreblabla relevant=yes foo.bar.2 relevant=no foo.bar.3 blablabla foo.bar.4 relevant=yes I want to retrieve all foo.bar lines where within the ...
0
votes
1answer
81 views

How do I grep the lines based on '.' (dot)? [duplicate]

Suppose I've file with the following contents: 123 251 7.8 951 Now I want to grep the lines having . I've tried: $ cat file | grep . 123 251 7.8 951 $ cat file | grep '.' 123 251 7.8 951 But ...
-1
votes
1answer
52 views

converting plain text information to csv or excel

I have file containing similar data, which i am trying to arrange in the similar way, below are the details. I modified the script as per the variables in the context unable to get the required ...
2
votes
2answers
54 views

How do I remove all but the last occurrence of a string?

I am trying to remove all occurrences of 2016/01/30 14:52:51: but the last one. I tried this: awk '{gsub(//,"2016/01/30 14:52:51: ",$1);print}' to replace all but the last occurrence with nothing, ...
1
vote
2answers
47 views

Add columns to a text file with set spacing in Bash

I am setting up a malware zone file in DNS which will point all hosts to a specific IP. The file is simply a list of hostnames. This is what I have now: googlle.in ...
1
vote
1answer
20 views

Merging text file directories

I have two directories: Libc-825 and Libc-1044. Imagine that version 1044 is newer, but buggy. Is there a way to merge these file trees? I have there C sources with not so big differences. I have ...
8
votes
7answers
356 views

Convert rows to columns

I have a file that includes details about VMs running in a hypervisor. We run some command and redirect the output to a file. And the is data available in the below format. Virtual Machine : OL6U5 ...
1
vote
2answers
34 views

awk alter the next line after a pattern match based on another pattern match

I have a file with lines such as: .... pattern1 100 200 300 pattern2 300 400 400 pattern1 300 900 700 pattern1 200 500 900 ... As shown in the above example, there are some lines where pattern2 ...
1
vote
2answers
37 views

How to replace string within parenthesis using using sed

I have the following string: col1|col2|col3+++++++++++A|1|a B|2|b C|3|c D|4|d (3 rows) I want to split this string so as to remove the string in the beginning till the last + symbol and then ...
0
votes
1answer
39 views

How do I remove “^M” from a file? [duplicate]

I have two "identical" files that I compare in diff, and it shows that every line is different, after looking at the file I found that one of them has ^M at the end of every line. How do I remove ...