It is always worth while using the interactive interpreter first:-
This is a simple longhand starter that requires nothing but a bash terminal.
OSX 10.12.4, default bash terminal.
@wisecracker, when using the shell's read command rather than a line processing external utility to process all the characters on the line, it is best to use IFS= to prevent the interpretation of whitespace (otherwise it would also match lines starting with 24). Likewise when printing the result, it is best to use printf to avoid interpretation by the non-standard echo command, that you previously avoided with the -r option.
So:
--
Note:
if
should syntactically be either
or
since ${var:pos:num} is bash/ksh93/zsh, one might also use:
Last edited by Scrutinizer; 04-27-2017 at 07:21 AM..
This prints 18th field where that field number - 18 - starts with a 24.
Your grep command does not match what you actually need, and neglected to mention the field requirement. It helps both you and the people helping you to give enough information to start with. The more you assume the less we can help you.
counts lines it does not print field #18. If you want find how many lines match then pipe the output of the above awk into wc -l
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Hello, I'm looking for sed solution to change
...
<li>keyword</li>
<li>keyword
<li>keyword</li>
<li>keyword
<li>keyword</li>
...
to
...
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
...
I.e., if lines beginning with <li> do not end with... (3 Replies)
Hi,
This must be simple but I can't get it to work. I have the follow code to insert the contents of a file into an array and then I want to print the value of a container where all of the records in another container within the array start with 33 (that's not all I want to do but it is all I... (2 Replies)
Hi guys,
I have got a file which doesn't have the same number of columns in each line. I would like to print the second column and the one that begins with 33= and has some numbers after '33='
Can you please help me asap?
Cheers (7 Replies)
Hi,
I have a bunch of images (8k) in several directories. I want to tar these directories up and unzip them to development and production with the same path.
Example:
/about/images/sample_01
/about/images/sample_02
/about/images/sample_03
/about/images/lorem_ipsum... (4 Replies)
Hello!
I wish to extract the pid where CPU is above 10%
last pid: 22621; load averages: 4.71, 5.04, 5.13 15:08:34
221 processes: 212 sleeping, 2 running, 1 stopped, 6 on cpu
CPU states: %... (3 Replies)