Manipulation of text by programs, scripts, etc.
0
votes
1answer
13 views
retrieving host name from email address
I am trying to go through individual emails and retrieve the host name.
Each email has a To: section with an email address "[email protected]". I'm trying to retrieve just "aol.com"
Eg:
To: abc123@aol....
1
vote
2answers
39 views
Remove comments in a C file [duplicate]
I am trying to remove comments from a file which may be in any part of a line and span multiple lines.
struct my_struct{
field1;
field2; /** comment 1
*/ field3;
/* comment 2 */
} ...
0
votes
3answers
27 views
Exclude lines that have less than 23 columns
I would like delete (exclude from output) some lines that have less than 23 columns in a file. For example:
BR1009298 338 1685 5839 1986 21111995 1 1 1 0 20032001 954 31266 1 1 4 5 205 95 27 3 2 ...
1
vote
3answers
35 views
Search and Replace value in HTML binary file in UNIX
I'm trying to search and replace some values in my already created HTML template.
Being a binary file, I've so far been unsuccessful in search and replacing my HTML.
I need to search for string 1111 ...
-1
votes
0answers
23 views
I need to combine two CSV files as per below requirement [on hold]
File 1
123,456
123,678
File 2
476, AAA, XYZ
678, BBB, LMN
Desired Output
123, 456, AAA, XYZ
123, 678, BBB, LMN
4
votes
6answers
580 views
How to concatenate three files (and skip the first line of one file) an send it as inputs to my program?
There are file A, B, C.
I want to concatenate file A, B and C (Skip first line of C).
And then send them to myProgram as input.
How can I write this in shell script?
I wrote that
cat A > file
...
0
votes
1answer
27 views
Transpose cvs file by the value of a column
Input:
X Y
1 11
1 12
2 21
2 22
Desired Output:
11 12
21 22
I want to transpose the cvs file by the value of column 1. In this example, for X = 1, transpose (11, 12)^T to (11, 12); for X = 2, ...
0
votes
1answer
33 views
inserting gaps in a text file using shell script
How can I insert gaps at certain places in a text file using shell script? For example, I want to insert enter after word "complete" wherever it is found in a text file.
0
votes
2answers
33 views
How to get the recent time updated row using linux?
The following table is the mysql database table(i.e select * from users)
I want the last updated time row using linux command?
+------------+----------+---------+--------------+--------------+------...
-1
votes
5answers
43 views
Remove Columns from a CSV File
I have a CSV file from which I need to remove one column from it.The problem is I have exported the CSV file without headers.So how can I remove the column from the CSV file.For example if I have the ...
0
votes
1answer
19 views
change ods to txt, with all columns from ods correctly distributed with tab delimiter
I know similar questions have been asked, but non seem to work for me. I have tried both odt2txt, unoconv and conversion to .csv rather than .txt. I need to find a way (within a bash script) to change ...
0
votes
1answer
26 views
How to rewrite lines in file? [duplicate]
In csv file couple of lines dont fit the data I need.
For example, this is my example.csv file:
14/Feb/2016:13:21:33-0500,mk
15/Feb/2016:14:21:33-0500,mk
16/Feb/2016:15:21:33-0500]http://map1.link.de/...
0
votes
2answers
22 views
Replacing string with other string
In line((s) that originate from csv file)
14/Feb/2016:15:21:33-0500]http://map1.link.de/mk
what is the easiest part to replace/delete&add
]http://map1.link.de/
with
,
having in mind that ...
-2
votes
3answers
58 views
Bash script : How to export file name as header to csv
I have multiple .txt files in my folder " Subj1 " arranged in following format
regional_vol_GM_atlas1.txt
regional_vol_GM_atlas1_prop.txt
....
regional_vol_GM_atlas152.txt
each file ...
0
votes
2answers
34 views
awk with multiple if and replacement
I'd like to do the equivalent of this in awk (for every line, from command line):
items = split(',')
if items[2] >= 10:
return items[0], items[1], 7
if 4 < items[2] < 10:
return items[0],...
5
votes
1answer
1k views
How to replace a word inside a .DOCX file using Linux command line?
I want to change a word in a .docx file using a shell command.
I tried using the sed command, but it is not working.
Does anyone know a solution for this?
For example, I want to change a word (e.g. ...
0
votes
4answers
50 views
How to identify, sort descending and display the top 10 blocks of text, by category
The history of transactions done on an entity within our systems look like below:
1 BYM1 TSTAB 09NOV 0035 CAB
Sometext 01
2 BYM1 TSTAB 09NOV 0035 CAB
Can be done - question
3 BYM1 TSTAB ...
1
vote
3answers
61 views
Filter columns basing on the value of other column
I have a text file with two columns and more than 3,00,000 rows. Format is as below
Filename1.txt Num1
Filename2.txt Num2
Filename3.txt Num3
I want to copy all the filenames for which the ...
1
vote
1answer
34 views
Trouble with sed
I've a file with information like this
Info A: 1
Info B: 2
Info C: 3
Info D: 4
Info A: 1
Info B: 2
Info C: 123
Info D: 4
Now I'm trying to get the line with Info C but I need it separately. I need ...
1
vote
3answers
61 views
How do I rearrange columns in a text file?
Month Name Marks
2016-10 Sam 58
2016-09 Sam 77
2016-10 John 64
2016-09 John 47
2016-10 Mark 71
2016-09 Mark 38
2016-10 Steve 83
2016-09 Steve 39
I fetch this data from my ...
4
votes
2answers
95 views
Replace lines matching a pattern with lines from another file in order
I want to replace the lines matching a pattern from one file from the lines in order from another file, for example, given:
file1.txt:
aaaaaa
bbbbbb
!! 1234
!! 4567
ccccc
ddddd
!! 1111
we like to ...
2
votes
2answers
40 views
find n most frequent words in a file with a stop words list from the command line
Hey i want to find the most frequent words in a text file, with using a stop words list. I already have this code:
tr -c '[:alnum:]' '[\n*]' < test.txt |
fgrep -v -w -f /usr/share/groff/current/...
0
votes
2answers
31 views
Add ;; to the top and bottom of each file in a list [duplicate]
I have a list of the locations of each text file that need this done inside add.txt
For example inside add.txt I have the following
/root/QuestDiary/MapQuest_Def/Mon_Umyounkijang.txt
/root/...
0
votes
2answers
44 views
find the line number in a file starting with a pattern from current line [closed]
How to find out the line number which starts with date in yyyy-mm-dd format from current line number? In the example below, i wanted to find out the line number of the line starts with 2016-10-09 gggg ...
0
votes
2answers
32 views
How can i extract the value of cluster from below line
I want to extract the value of clusterName="BYSL_Dev" from the below line
<xmi:id="test.cim " name="test" clusterName="BYDev" developmentMode="false" parallelStartEnabled="true"> <...
1
vote
3answers
46 views
text processing (reading and computing from two files) [awk, script]
I have one text like the following: (words, word domains)
car transport
car machine
bank economy
bank politics
bank parks
God religion
...
There are numerous words, some words have different domains ...
7
votes
5answers
480 views
Is there any alternative to the “sed -i” command in Solaris?
I have a requirement in my project to replace some existing text in a file like foo with some other text like fooofoo:
abc.txt
name
foo
foo1
So I tried:
sed -i "s/foo/fooofoo/g" abc.txt
However I ...
3
votes
3answers
102 views
Editing files with shell script
I'm developing a script, and it perform calculations that need to include in a text file already filled.
The format of the file lines is:
1 20/10/16 12:00 take car in the garage joe's garage
Inside ...
0
votes
2answers
31 views
gawk - Dynamic creation of text file using input file fields
I have a text file that looks like this:
UICEX_0001 UICEX_0001_T1.bam UICEX_0001_C2.bam chr1:16946335 chr19:9064309 chr8:10480278 ...
2
votes
3answers
37 views
command to extract data between 2 rows
I have to extract the exception and corresponding stack trace starting from a line number in a log file. I know the starting line no of the error. how can i find out where the stack trace will end ...
1
vote
1answer
23 views
Extract all lines from a word to another with my match in between
I have a file with the following structure:
[Term]
id: GO:0000001
name: mitochondrion inheritance
namespace: biological_process
def: "The distribution of mitochondria, including the mitochondrial ...
0
votes
2answers
55 views
Adding repeating line numbers
I have a file with about 10k lines. I would like to add the line numbers to the first column, but in a way to repeat the line numbers 1-100. For example,
1 12313
2 3434
.
.
.
100 4233
1 24523
.
.
.
...
1
vote
2answers
23 views
Find the first number, then return the rest of the string
Using Bash, how can I find the first number in a string and then take the rest of the string?
For example, I have the following string -
SomeText.MoreText.Whatever.1.2.3.4-branch.ext
And I wish ...
0
votes
1answer
24 views
How to print 2 texts in two columns
I have 2 text in different files file1 and file2. I need a command that takes file1 and file2 as arguments and print on terminal
This is text 1. This is This is text 2. This is
text 1....
2
votes
3answers
40 views
Change lines in file only if they match the patterns in another file
Say I have these two files:
inp
11 hello
22 wonderful
33 beach
44 today
55 is
66 great
pats
11
44
55
I want to do something in inp, but only for lines that are in pats. E.g. say I want to append +...
0
votes
2answers
39 views
How do I use each line of a text file to select lines with matching string in a second text file? [duplicate]
Suppose I have two text files - active-users.txt and all-user-info.txt
active-users.txt contains only numeric userIDs.
all-users.txt contains userIDs, and additional info fields.
What I need to do ...
-1
votes
1answer
35 views
Change the position of string in line
I would like to move the first string between > and the first _ to the second position after the first _
This is to transform this:
>10E13JB10_Vacares_8__a1
blablabla
>...
2
votes
5answers
78 views
How to display the final paragraph of a text document?
say I have three small paragraphs, word count is or a tad more than 100 how do I only show the final paragraph?
2
votes
1answer
28 views
How to adjust cli output into pretty columns
Let's say I have some CLI one-liner, which outputs some lines of text with space-separated parts. Those parts should logically be columns, but because of text width it doesn't look so.
How could I ...
-1
votes
3answers
65 views
Replace text in a file from another file
Say I have a file called before.txt which reads:
1
2
3
4
but want to replace the number 4 with a number (in order) from a text file called after.txt. How would I do so?
after.txt contains:...
-3
votes
0answers
27 views
Changing multiple line records to a single line format record [on hold]
Input File
CLASS
EG07GER
AAA BBBBBB CCCCCCCC DDDDDD
0 16 6 0
EEEEEE
5
AAA BBBBBB CCCCCCCC DDDDDD
2 32 0 ...
1
vote
0answers
56 views
Swap two words using sed/awk without using third word [closed]
Sample File:
TOM abcd HARRY
HARRY TOM
HARRY HARRY
Output should be like this:
HARRY abcd TOM
TOM HARRY
TOM TOM
1
vote
4answers
44 views
How to accumulate some values within a column based on information in another column from the same data file ?
I have a data file looks like:
c1.11 SNP1 -6.73098 0.764833 Chr1:1
c1.21 SNP2 -4.871 0.00393002 Chr1:101
c1.12 SNP3 -0.766822 0.0891227 Chr1:201
c1.22 SNP4 11.7499 0....
1
vote
2answers
38 views
adding letters and character in a column using awk or sed?
I have a file which look like this:
A3 124.406526 8.281803
A3' 125.000684 8.389677
K4 123.072842 8.166373
K4' 120.092553 8.269080
I want to add characters in the 1st column, and the file will should ...
0
votes
5answers
60 views
How to sed certain expression?
I am dealing with this for some time now and without success.
I need to sed this
1.0.0/hk/base/9/7/56.png2003444
into this
hk,9,7,56,200,3444
Any help would be appriciated.
Edit.
First line ...
0
votes
1answer
90 views
Reading multiple inputs from a .txt file
I want to use the list of phone numbers(many) in a file "input_loan_msisdn.txt" as input to my script (the phone numbers in the file are listed line by line), and use it as a keyword to grep my output ...
3
votes
2answers
76 views
how to delete some of the rows in first file based on information from a second file?
I have a file like this:
file 1:
1 2 0.000
1 3 0.213
1 4 0.014
1 5 0.001
1 6 0.555
1 7 0.509
1 8 0.509
3 4 ...
-2
votes
2answers
43 views
How to add commas (based on count in a line, igonoring the comma in the double quote text) at the end of each line?
Below a sample of data.
What I want to achieve is, I have to count the number of commas in each line ( Also I have to ignore the commas of a string which is in double quotes ("")). If the number of ...
0
votes
5answers
52 views
How to split a huge line of characters into several lines with equal numbers of columns?
If a data file looks like:
snp200 snp1 snp100 snp32 1 1 0 2 0 0 0 2 2 2 2 1...
how can I break the line when snp.. finish and use them as column names and then divide the rest of digits equally (...
0
votes
4answers
40 views
How to separate the sequence of characters (digits) with space
I have this situation:
my data:
ID01 120120101
ID02 101010101
ID03 210210210
ID04 505052120
And I wanted this data: output
ID01 1 2 0 1 2 0 1 0 1
ID02 1 0 1 0 1 0 1 0 1
ID03 2 1 0 2 1 0 2 1 0
...