I was using the return value of fgrep -s 'text' /folder/*.txt to find if 'text' is in any .txt file in /folder/. It works, but I find it too slow for what I need, like if it searches for 'text' in all the files before giving me an answer.
I need something that quickly gives me a yes/no answer when it finds at least one file with the 't...
Hi
Is there any script that would transform a tab delimited data file into libSVM data format? For an example my unlabelled data:
-1 9.45 1.44 8.90
-1 8.12 7.11 8.90
-1 8.11 6.12 8.78
and I would like to append each value with a label:
-1 1:9.45 2:1.44 3:8.90
-1 1:8.12 2:7.11 3:8.90
-1 1:8.11 2:6.12 3:8.78
I believe this can b...
I have a variable with the following contents: "a b c d e f g h i j k l", how would you go about adding a comma sign (,) after each third member so it looks like this: "a b c, d e f, g h i, j k l".
Initially all my variable data is stored in an array so if anyone knows how to directly manipulate the array, it would be great.
Thanks in ...
Hello, guys!
Since I've converted to the Church of Emacs, I've been trying to do everything from inside it, and I was wondering how to do some text processing quickly and efficiently with it.
As an example, let's take this list that I was editing some minutes ago on org-mode.
** Diego: b QI
** bruno-gil: b QI
** Koma: jo
** um: rsrs ...
My script takes a file name in the form R#TYPE.TXT (# is a number and TYPE is two or three characters).
I want my script to give me TYPE. What should I do to get it? Guess I need to use awk and sed.
I'm using /bin/sh (which is a requirement)
...
What I need to do is parse a string of the following form
-option optionArgument, --alternativeNotation Some text, nothing of interest...
I set the FS to
BEGIN {
FS = ",?\ +"
}
but it didn't work... it should break on every random number of blanks (at least one), preceeded by a comma (optional). Any ideas?
Thx in advance,
...
Using sed or similar how would you extract lines from a file? If I wanted lines 1, 5, 1010, 20503 from a file, how would I get these 4 lines?
What if I have a fairly large number of lines I need to extract?
If I had a file with 100 lines, each representing a line number that I wanted to extract from another file, how would I do that?
...
I want the variable sum/NR to be printed side-by-side in each iteration. How do we avoid awk from printing newline in each iteration ? In my code a newline is printed by default in each iteration
for file in cg_c ep_c is_c tau xhpl
printf "\n $file" >> to-plot.xls
for f in 2.54 1.60 800
awk '{sum+=$3}; END {print sum/NR}'...
I have a 200 Mb text file and for every line need to swap the 3rd and 4th characters with the 6th and 7th characters, so that
1234567890
would become
1267534890
I am using Windows XP with PowerShell installed. Also installed is Cygwin and UnxUtils so have access to versions of cut, sed, awk, grep, etc. There is no delimiter in the fi...
Hi there!
I want to embed an awk script inside a shell script but I have trouble to do so as I don't know where to end a statement with a ; and where not.
Here's my script
#!/bin/sh
awk='
BEGIN {FS = ",?+" }
# removes all backspaces preceded by any char except _
function format() {
gsub("[^_]\b", "")
}
function getOptions() {
...
What I'm trying to achieve is the difference between chapter 1 start time and chapter 2 start time and so on subtracting each chapter start time from the next in the array e.g. 00:05:57 - 00:01:03 = 00:04:54
$ cat ChapterStart
00:00:00 00:01:03 00:05:57 00:08:27 00:11:58 00:14:50 00:20:19 00:25:06 00:33:17 00:38:21 00:42:30 00:46:11 00...
#!/bin/sh
find ${*-.} -type f -print | xargs file |
awk '{
$1=NULL;
t[$0]++;
}
end {
for (i in t) printf("%d\t%s\n", t[i], i);
}' | sort -nr
The first "find" line works. But the awk part does not work. I expect the count of file types sorted in descending order.
...
i have some xml files in linux
a="xx
xx
xx"
b="y
y
y"
How to replace the content and becomes
a="xx\n\xx\nxx"
b="y
y
y"
where attribute b is not replace
i have try this but how to support multi files and replace the attribute "a" only using sed or awk command; (not use xslt)
sed ':a;N;$!ba;s/\n/\\n/g' abc.xml
...
Hi,
Im have a xml config file called solrconfig.xml, it has this section in the middle of it:
<!--############ BEGIN replication settings DO NOT EDIT ################################-->
<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replic...
Hi, I have a text file with lots of lines and with this structure:
[('name_1a',
'name_1b',
value_1),
('name_2a',
'name_2b',
value_2),
.....
.....
('name_XXXa',
'name_XXXb',
value_XXX)]
I would like to convert it to:
name_1a, name_1b, value_1
name_2a, name_2b, value_2
......
name_XXXa, name_XXXb, value_XXX
I wonder what would be the...
I've been trying to write a shell script to travel a directory tree and play every mp3 file it finds. afplay is my utility of choice, given that I am on a mac. However, afplay only takes one argument at a time, so you have to call it over and over again if you want it to keep playing. It seems like the simplest solution would be as follo...
Hi,
I made a awk script to do stuff on some input files but as I want to avoid installing gawk on the windows machines I want this awk script to be available as a webservice or just a form where I can either upload a file or just copy the text of the file in a box and run the script on it and get back the result of the awk script.
How ...
I have very little experience with AWK, but it seems like the best tool for my purpose now.
I am trying to get a list of nearby BSSIDs by using the airport -s command in OS X. Output looks like this:
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
MyWireless 00:11:22:33:44:55 -85 64 ...
When I google for something, I get the count.
Results 1 - 10 of about 800
Is there any API or something like that to capture the number "800"?
I have a database of a few thousand words and I want the google count against it.
...
Hi, I am new to linux and am trying to parse a bunch of files that looks as follows -
Some text
start list some other text
start sublist1
continue sublist1
more elements
more elements2
a sublist2
a sub-sublist1
Where all the spaces before the list are tabs. I need a way to parse the text so that a colon is added for sublist...