11-10-2008
Thanks All for your help...
But all code which you posted does not work as what I expected. Please, see my desired output below.
I try to explain again more clearly..
If an X or consecutive Xs followed by 0 is count as occurrence 1
e.g: X0 , XX0, XXX0, XXXX0, ... count as occurrence 1
Here is my Input Data:
1 0
2 0
3 0
4 X
5 0
6 X
7 0
8 0
9 0
10 0
11 X
12 0
13 X
14 X
15 0
16 X
17 X
18 X
19 0
20 X
21 X
22 0
23 0
24 0
25 0
26 X
27 X
28 X
29 X
30 X
31 0
32 0
33 0
If it arrange in Line:
000X0X0000X0XX0XXX0XX0000XXXXX000
Then, we can distinguishes as follow:
000
X0X0 000
X0XX0XXX0XX0 0000
XXXXX0 00
X0X0 = count as occurrence
2(there are two X0s)
(
X0-X0 = 2 Occurrences )
X0XX0XXX0XX0 = count as occurrence
4
(
X0-XX0-XXX0-XX0 = 4 Occurances )
XXXXX0 = count as occurrence 1
So, My Desired Output is:
2
4
1
I hope you can understand my explanation
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
2. Shell Programming and Scripting
hi,
i have a file having datas like that
./a.txt
12344
12345
12346
12347
.....
.....
...
i want to save this datas to another file like that
./b.txt
12344 12345 12346 12347 ... ... ...
i think awk can make this but how? :) waiting for ur help. (3 Replies)
Discussion started by: mercury
3 Replies
3. Shell Programming and Scripting
hi all,
i have a file that contains the following kind of data
codeexpert_package_module1.html
codeexpert_package_module2.html
codeexpert_package_module3_revision2.html
and it goes on ..
i need to get the following data from it
package_module1
package_module2
i know basename... (4 Replies)
Discussion started by: sais
4 Replies
4. Shell Programming and Scripting
hi All,
cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'
Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies
5. Shell Programming and Scripting
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Discussion started by: shis100
7 Replies
6. Shell Programming and Scripting
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Discussion started by: timmywong
8 Replies
7. Linux
Please help me, wasted hrs:wall:, to find this soulution:-
I need a command that will work on file (xml) and replace multiple occurrence (more than 2 times)
Examples
1. '==='
2. '===='
3. '======='
should be replaced by just '=='
Note :- single character should be replaced. (=... (13 Replies)
Discussion started by: RedRocks!!
13 Replies
8. Post Here to Contact Site Administrators and Moderators
Majority of the questions are pertaining file/string parsing w.r.t
sed
or
awk
It would be nice to have these two as their own sub category under shell-programming-scripting which can avoid lot of duplicate posts. (1 Reply)
Discussion started by: jville
1 Replies
9. Shell Programming and Scripting
Hi Experts ,
file:
EST 2013::.................................................................................................................................................................................................................................................cmihx021:/home/data1/
... (11 Replies)
Discussion started by: rveri
11 Replies
10. Shell Programming and Scripting
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
LEARN ABOUT LINUX
set_color
set_color(1) fish set_color(1)
NAME
set_color - set_color - set the terminal color
set_color - set the terminal color
Synopsis
set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR]
Description
Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple,
cyan, white and normal.
o -b, --background Set the background color
o -c, --print-colors Prints a list of all valid color names
o -h, --help Display help message and exit
o -o, --bold Set bold or extra bright mode
o -u, --underline Set underlined mode
o -v, --version Display version and exit
Calling set_color normal will set the terminal color to whatever is the default color of the terminal.
Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey
font color, while set_color --bold white will result in a white font color.
Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator.
set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and
incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of
ncurses and recompile fish against it in order to fix this issue.
Version 1.23.1 Sun Jan 8 2012 set_color(1)