Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Hi all,
I am new to shell scripting. And I have a task to do, I tried all possible ways to solve this, but didn't. Iwas wondering maybe someone could help me.
So I have a random file something like this
Andrew John Mike
Alfa Omega Beta
And I need to create scrip witch would filter any file like this:
- Find two most repeated symbols in file ( in this file I think it would be "a")
- Find most repeated line end in this file
- And symbol combination, witch is not in combination of symbols witch i entered
like this "joh"
And write all these to new file
I am really appreciate if someone would help me.
Thank You.
3. The attempts at a solution (include all code and scripts):
I tried this:
Well i tried many diffrent ways, I don't know solution for first task, so I can't go any further, cause other tasks are familiar. I just can't go on. Help please .
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Kaunas College, Kaunas, Lithuania, first course, proffesor R.Kraunevičienė
Last edited by Scott; 04-25-2011 at 03:52 PM..
Reason: Added code tags
${#mas[@]} This returns one single number, so the for-loop will loop once on i=3 then break. I think you meant for STR in "${mas[@]}" to loop over all elements in the array.
If you have to read from a file, start there:
Then you could just print each STR char by char:
for ((N=0; N<${#STR}; N++)) ; do echo "${STR:$N:1}" ; done
Then pipe the entire outer 'while read' loop through sort, which will make a file like
which you can then pipe into uniq -c to count them for you:
...then sort | tail -n 2 to get the bottom two.
Not the most efficient solution perhaps, but counting chars is a bit awkward to do in shell.
You're redirecting the file into the entire while loop, not just into 'read'. That <filename at the bottom is where you want to put the file. All read -A band does is tell read to read stdin into the array 'band'.
You've got one too many done's.
If you copy-paste the loop I have it will work(change ... into true), then you can add onto it.
I don't exactly understand what ARR means, is it my array from band file?
so it's something like this [jonas algis andrius] ?
[tomas rimas karolis]
[saulius justas domas]
Well, what is line 5? I can't tell from what you pasted where the file begins or ends. #!/bin/bash has to be the very first line or you might not get the bash shell. Also try running it with 'bash filename.sh'
Quote:
I don't exactly understand what ARR means, is it my array from band file?
ARR is an array. On the first loop, ARR[0] will be jonas, ARR[1] will be algis, ARR[2] will be andrius.
So I done everything You told. Sorry to bother You with my low skills with shell.
Now I have this code
Then I bash it:
So I understand it, it finds 3 elements in every line like 3 words in every line, that's ok, but it takes only last one of these "domas" not all of them in one line and then I can't sort this.
In following attached 748phy.xls file, fifth column is ST_Date, which contains time and dates in this format
22-11-2012 7:54:54 PM in single column
I want it to split in this format either 1st column 22/11/2012 and in second column 7:54:54 PM
Or like this in separate... (13 Replies)
input file's one set header is this,
-----------------------------------------------------
OUTPUT FROM ASCII FILE: CAST #1
-----------------------------------------------------
CC Cruise Latitude Longitude YYYY MM DD Time Cast #Levels
CA 8504 50.083 -144.883 1970 1 2... (6 Replies)
Hi all,
I am new to shell scripting. And I have a task to do, I tried all possible ways to solve this, but didn't. Iwas wondering maybe someone could help me.
So I have a random file something like this
Andrew John Mike
Alfa Omega Beta
And I need to create scrip witch would filter any... (1 Reply)
Hi all,
I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first.
Can you please help me determine which one to... (14 Replies)
Hi
How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
I have an task definition listing xml file that contains a list of tasks such as
<TASKLIST
<TASK definition="Completion date" id="Taskname1" Some other
<CODE name="Code12"
<Parameter pname="Dog" input="5.6" units="feet" etc /Parameter>
<Parameter... (3 Replies)
I have a file contains
TASK gsnmpproxy {
CommandLine = $SMCHOME/bin/gsnmpProxy.exe
}
TASK gsnmpdbgui {
CommandLine = $SMCHOME/bin/gsnmpdbgui.exe
I would like to comment and than uncomment specific task eg TASK gsnmpproxy
Pls suggest how to do in shell script (9 Replies)
Hi
I have a file consists of the following similar lines (10 mb file)
2008-05-15 02:15:38,268 RMSConnectionFactory - Setting session state for connection.
2008-05-15 02:15:38,277 RMSConnectionFactory - Returning WS connection.
My task is to find out any missing second lines for... (14 Replies)