Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

0
votes
1answer
28 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
31 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
25 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
0answers
21 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
155 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
38 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
18 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
29 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. ...
4
votes
2answers
66 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
81 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
12 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
26 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
38 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
34 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
74 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
72 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
51 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
65 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
38 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
135 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
79 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
50 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
51 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 ...
7
votes
7answers
353 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
31 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
38 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 ...
1
vote
1answer
43 views

transpose sets of three rows to columns

I have a file that has below entries: [root@ovmm329 ovm_utils]# cat /tmp/disk.txt Physical Disk : 'IBM (67) device=/dev/mapper/360050768018206483000000000000453 shareddisk=true Physical Disk : 'IBM ...
1
vote
3answers
67 views

Trim a specific field and replace in Unix Shell Script

I have a file with below data: 5773|2015-11-19|2016418|O|2015-11-06|C|AB1CD|826|826|CDE|2015-11-19|22222222222222222222222222222|ABCD|AB|30 ...
0
votes
2answers
19 views

sed + search word with strings and replaced all word

I want to create with sed the following: For example each word in the file that have the ssss... Should be replaced (all word) with target string as gggg. echo "duwdbnhb ssssssmnfkejfnei" | sed ...
1
vote
3answers
36 views

How to join two files by matching a column with an irregular number of columns?

file1: 0000002|SLM DEV CORP |PO 857 0000003|S TOPPING |APT 19 0000004|JD BROS LTD ...
0
votes
1answer
18 views

Insert Line in File When Group of Lines Changes

Let's say I have a text file like this: group1 hello group1 there group1 nice line group2 here group2 we group2 go What I want to do is insert a line when the group of lines changes, something ...
0
votes
1answer
41 views

sed appending filenames on newline

I am trying to add filenames to many *txt files, which are tab-seperated (they will eventually be joined together using cat) I am using bash, on Ubuntu 14.04. So far my code is; for f in *.txt do ...
12
votes
8answers
923 views

Remove extra header lines from file, except for the first line

I have a file that looks like this toy example. My actual file has 4 million lines, about 10 of which I need to delete. ID Data1 Data2 1 100 100 2 100 200 3 200 100 ID Data1 ...
0
votes
2answers
25 views

Group and total of a list

Using bash, is it possible to get a count of entries from a list, for example, for the list a b a cccc b a The desired output would be something like a 3 b 2 cccc 1
5
votes
5answers
333 views

How to group lines in file by two?

I have a text file like this: a b c d e f g How can I group those lines to obtain an output like this: a-b b-c c-d d-e e-f f-g I have to do this in shell (sh, csh, bash). I have found this: ...
2
votes
4answers
118 views

How to delete everything after a certain pattern or a string in a file?

Suppose I have a list of URLs in a text file: google.com/funny unix.stackexchange.com/questions isuckatunix.com/ireallydo I want to delete everything that comes after '.com'. Expected Results: ...
0
votes
1answer
41 views

How can I exclude the lines which matche the range patterns in sed?

I am writing sed expression which tries to print the text within a range of patterns: apt-cache showpkg gdm | sed -n '/Reverse Depends:/,/Dependencies:/ p' This basically works, current output is: ...
1
vote
3answers
49 views

Merging 2 files and keeping the one duplicate

I want to create a file that contains columns from two input files. File1 is like: 11111111 abc12345 Y 22222222 xyz23456 Y File2: 11111111 abc12345 33333333 ...
0
votes
2answers
67 views

Grep / awk on multiple files to single output

I have several txt-files containing data, where i use grep to search for a current string of text, and use awk to filter out the variable i need. The string is repeated through the file, so i ...
0
votes
4answers
42 views

grep all the lines in a file and write line to a file from the pattern matching point

For example, a temp.txt file contains information like below: adsf on line jhkjhvjdbvjvbvbdjkvn qerwtt on line fdgdgdgdd qwqertg on line safffasffaf wrt on line adaddsd I want to grep for ...
1
vote
2answers
47 views

How do I remove text blocks within a log file? [closed]

I have the following log: 2016/01/20 00:00:16.035 [T114BaseServlet] ... Blah Blah Blah 2016/01/20 00:00:16.036 [ApplicationState] ... Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah ...
1
vote
3answers
26 views

How do I replace this pattern with a newline inside it? [duplicate]

If I have a text file with this content: someline <!--\ file first read on 2015/01/11 And I want to delete <!--\ and everything until what comes after "on", how do I do it? The ...
5
votes
2answers
28 views

diff consuming huge amount of memory and cpu

I have two files, all.txt (525,953,272 records) and subset.txt (525,298,281 records). Each record is nothing but a 17-digit ASCII integer. Both files have been sorted, and duplicate records within ...