Tagged Questions
2
votes
3answers
94 views
Easy way to parse syslog date format
I'd like to write a script that analyses the last week's syslog.
But my syslog logs in a stupid date format, e.g. "May 22". If it logged as 2013-05-22, this task would be trivial.
Is there a way ...
3
votes
3answers
75 views
sed + how to remove character/s that start or ended on each number
How do I remove the . character(s) that start in the beginning of each number or end on each number?
Remark – perl one liner also good alternative for sed.
Example input:
.23.12.44.5.
.233.3.3.3
...
5
votes
5answers
206 views
How to remove multiple blank lines from a file?
I have some text-files I use to take notes in - just plain text, usually just using cat >> file. Occasionally I use a blank line or two (just return - the new-line character) to specify a new ...
1
vote
2answers
37 views
Trimming one part if equal to another part?
I use an e-mail quote attribution string like this:
On dd mmm yyyy hh:mm +hhmm, from info@example.org (Example Dot Org):
where info@example.org is the sender's e-mail address and Example Dot Org is ...
0
votes
2answers
87 views
Reordering strings in linux
How can I change lines around using the command line?
e.g. I have these lines:
Acct-Status-Type = Start
User-Name = "37XXXXXXX"
Event-Timestamp = "Apr 12 2013 15:56:55 AMT"
I need to ...
4
votes
3answers
144 views
Delete XML node containing certain element
I want to remove all Placemarks from a KML file that contain the element <tessellate>. The following block should be wholly removed:
<Placemark>
...
0
votes
3answers
50 views
Grep end regex matching
On OS X, system_profiler SPHardwareDataType outputs:
Hardware Overview:
Model Name: MacBook Pro
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 8 MB
Memory: 8 GB
I want to ...
1
vote
3answers
173 views
awk, sed, grep, perl… which to print out in this case?
I have this syntax in a file (http response times from analog):
<thead><tr><th class="x">seconds</th><th class="R">reqs</th><th ...
1
vote
3answers
267 views
linux/solaris + verify duplicate valid IP address from file
what the best way to find duplicate IP from file ( I have ksh script in this script I need to write function that check for duplicate IP )
for example if IP - 192.1926.23.52 exists twice in file - ...
1
vote
5answers
208 views
Replacing lines in files with file contents
I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like
foo
<?php
include("file1.php");
?>
bar
baz
<?php
...
0
votes
1answer
395 views
Linux + replace STRING/WORD in file according to rule
My target is to replace any word/string/Any characters in file
with new word/string according to the following rules:
If numeric characters on the left side of word/string then we not replace the ...
2
votes
4answers
326 views
Replace all but a set of characters in a file with newline
how to delete all characters in file except numbers and "." ,
each word (numbers/dot) should be in new line in file see example2
the solution can be with sed or awk or ksh syntax
remark - ...
0
votes
3answers
64 views
Fixing header and print
I have header starting with '>' and I want fix the header by keeping first word and removing other shown as in output.txt and print it
input.txt
>AGAJ01065549.1 ...
0
votes
3answers
224 views
Split and print
I have tab-demlimted text file with 50,000lines. I want to split the first column and print as shown in output.txt
Input.txt
rt|371443144|mb|MN556661.1| 2200443 A
rt|371443344|mb|MN556645.1| ...
5
votes
2answers
323 views
Replacing missing value blank space with zero
I have input.txt tab-delimited text file around 30K lines, I would like to check each row (s1..s30K lines) for missing value (i.e blank space) and fill the missing value with zero value.See out.txt
...
1
vote
1answer
157 views
Combining files with 4 columns each, into 4 files for each column [closed]
So I have a bunch of text files which look like this:
T1
r1 a b c d
r2 d e f g
...
T2
r1 h i j k
r2 l m n o
...
And I want to make FOUR different text files in the following ...
1
vote
5answers
152 views
frequency of occurence
I have a tab-delimited text file, that is around 3K lines long.
I want to calculate frequency of data appearing in it, in 10,000 ranges.
Input.txt
Price
500
1500
10001
15000
17000
...
2
votes
4answers
166 views
Output some sections of a text file [closed]
I have input like the following:
>gi|481443199|gb|MH447771.1|
49 0 0 0 1
50 0 0 1 0
>gi|987078004|gb|RTYJ01067061.1|
412 0 0 1 ...
2
votes
3answers
411 views
Average rows with same first column
Given a file with two columns:
Id ht
510 69
510 67
510 65
5l0 62
510 59
601 29
601 26
601 21
601 20
I need a way to coalesce all rows with the same ID into one that has an average height. In this ...
2
votes
3answers
1k views
Extracting column from comma separated text
I have a long comma-separated delimited file with 20K lines. Here's a sample:
"","id","number1","number2","number3","number4","number5","number6","number7"
...
2
votes
3answers
81 views
Need to parse a double entry table with two pairs
I have this two-entry table resulting from a program output:
Variable1 : Value1
Variable2 : Value2
Variable3 : Value3
Variable4 : Value4
Variable5 : Value5
Variable6 : Value6
...
0
votes
2answers
169 views
Getting data from matching list
list.txt
GETID_17049_knownids_1/2_Confidence_0.625_Length_2532
GETID_9248_knownids_6/10_Confidence_0.439_Length_2474
GETID_11084_knownids_3/3_Confidence_0.600_Length_1451
...
1
vote
3answers
1k views
sed/awk/perl - delete spaces between two strings/words + solaris 10
please advice how to delete the spaces between "=" to the value/string ( after the "=" character) , should be implemented by awk or sed or perl command and command must to fit for solaris OS , ( ...
3
votes
2answers
100 views
Column mismatch and substituting
input.txt (tab-delimted)
TTTTOTTT00000000008 RTTTT899 5.00E-28
TTTTOTTT00000000046 RTTTWRR 3.00E-31
TTTTOTTT00000000051 2.00E-11
TTTTOTTT00000000051 7.00E-12
TTTTOTTT00000000054 ...
2
votes
2answers
189 views
Get row data for non-matching column values
I want to read the file (1600 rows) and get rows only the columns have different values (sno1, sno2, sno3 & sno4-should be not be equal value) and it should be above
50%.The example of output ...
3
votes
2answers
171 views
Print row contain maximum and minimum value
I need to read the file (contains 16K rows)and print the entire row if any of columns and all columns contains max value (100) and all columns contain min value (0).The ouput example is given
...
4
votes
2answers
3k views
Compare two file columns
I have long text files with space-delimited fields:
cat file1.txt
Id leng sal mon
25671 34343 56565 5565
44888 56565 45554 6868
23343 23423 26226 6224
77765 88688 87464 6848
66776 23343 63463 ...
3
votes
2answers
256 views
Parsing a text-file table and aggregating information
I have long text file with the following columns, space-delimited:
Id Pos Ref Var Cn SF:R1 SR He Ho NC
cm|371443199 22 G A R Pass:8 0 1 0 0
...
2
votes
1answer
170 views
Is it a good idea to supplement shell script with perl purely for use of regex?
I'm looking for a simple way to utilize regex in a UNIX shell script where not every system will have perl extensions built into grep. What is really helpful about perl regex here is back/forward ...
8
votes
6answers
734 views
Delete lines beginning with #
How do I delete lines beginning with a #, given that there can be whitespace on the left and right of the #?
# Master socket provides access to userdb information. It's typically
5
votes
3answers
532 views
Regex & Sed/Perl: Match word that ISN'T preceded by another word
I'd like to use sed or perl to replace all occurrences of a word that doesn't have a certain word in front of it.
For example, I have a text file that contains a plot of a movie and I want to replace ...
3
votes
3answers
166 views
What does . match?
In working with regular expressions, I have been told that a dot character . will match everything.
Except for newlines \n.
Are there any other exceptions? What about the NUL character \0, or the ...
1
vote
1answer
384 views
How to convert <a href=“http://xy.com”>XY</a> to [http://xy.com XY]?
Just for editing Wiki's..
So i have this input [from a larget text]:
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT <a ...
3
votes
4answers
597 views
Replacing text from a list of replacements. Added complication: backslashes
I have a file A that contains pairs of strings, one per line:
\old1 \new1
\old2 \new2
.....
I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
