You do not need to use awk to parse each line. You can set the IFS to ';'
and simply read each line into an array (i.e. myarray) as shown in the following
code snippet.
To reduce run time you need to use shell builtins as much as possible and not
call external programs such as awk.
I have been working on some code for a while, that will parse a log file, look for a specified time discrepancy between entries, and then print that line +/- n other lines out to a file...
#!/bin/bash
file=$1 # The input log file
maxTime=$2 # The time discrepancy to look for
n=$3 ... (1 Reply)
dear pro-coders,
is there any command out there that takes out the front spaces from a string?
sample strings:
4 members
5 members
3 members
but it has to be like so:
4 members
5 members
3 members (3 Replies)
Hi all!
i need your help.
I'm getting started with this...
in need to insert in an array string values. But the thing is that this strings have blank spaces...
for example if a want to put "filed1 = " and "field2 = " .... in the array , when i want to print all the fields, it only shows... (4 Replies)
Forgive me. I am very new to kornshell scripts. The simplest things stop me dead in my tracks.
Here are two such examples.
I want to save the first 19 characters of the following string to a variable.
"Operation Completed and blah blah blah"
I know this works (from another thread):
... (2 Replies)
Hi,
Could someone has any suggestions on this? When read a line from a file, I need to check the first char in the line, it could be a space or any char. But the leading spaces are removed by read.
Thanks. (2 Replies)
Hi,
Well as the title says, I have an array of strings (delimited by null). The length of the array is variable and length of each string is variable as well. What I need is one huge string with the original strings in the array separated by spaces.
For example is an array is such that array... (12 Replies)
'String' file contains the following contents,
D11, D31, D92, D29, D24,
using ksh, I want to remove all white spaces between characters no matter how long the string is.
Would you please give me some help? (1 Reply)
I have a file, names(i) where each entry is 'first last' name. 'cat names' is fine. But in a shell script
>for file in $(cat names)
> do
> echo $file
> done
the first and last name appear on 2 lines. I have tried escaping and quoting the space but to no avail. The names are to be... (4 Replies)
I'm having issue capturing a value from file.list with a multiple spaces in a variable $i, tried various options like using double quotes, no quotes, single quotes, curly braces but to no avail.
cat file.list
aaa test bbb
ccc test ddd
eee test fff
for i in `cat file.list`
do
echo "$i";... (2 Replies)
Hi
I'm trying to loop through an array that contains other arrays and these arrays consist of strings with spaces. The problem is that I can't seem to preserve the spacing in the string. The string with spaces are either divided into multiple items if I change IFS to \n or all the elements of... (4 Replies)