If your awk version supports the sub() string function *and* if your record always have the same layout, here is another way of doing it:
Or, if you hate the one-liner style of coding: Edit: By reading the OP, I just realized that I stopped at the first request. So, go for the Radoulov's snippet. I can't think of anything better.
I am a beginner at shell scripting, actually i am working on my first script right now.
Anyway i have searched the world how to grep two letters from each word (it will always just be two words).
For example:
Example Blablabla
I want my script to cut out Ex (from the first word) and Bl... (4 Replies)
Hi
Is there a way to cut the last two characters off a word or number given that this word or number can be of varying length?
I have tried something like
TEST=`echo $OLD | cut -c 1-5`
where $OLD is a variable containing a number like 1234567 which gives a result of 12345. This is fine... (4 Replies)
Hi,
From the file "example" with lines like below, I need the int value associated with ENG , i.e, 123
SUB: ENG123, GROUP 1
SUB: HIS124, GROUP 1
..
..
Normally , i do
grep ENG example | cut -d ' ' -f 2 | cut -c 4-6
Is it possible to do it in simpler way using awk/sed ?
... (5 Replies)
Hi,
I am cutting data from a fixed length test file and then writing out a new record using the echo command, the problem I have is how to stop multiple spaces from being written to the output file as a single space.
Example:
cat filea | while read line
do
field1=`echo $line | cut -c1-2`
... (6 Replies)
hi people,
I have a text file containing data, seperated by TAB. I want to process this tab'ed data as variable. how can I assign this?
Ex:
Code:
11aaa 12000 13aaa 14aaa 15aaa 16aaa 17aaa
21aaa 22000 23aaa 24aaa 25aaa 26aaa 27aaa
31aaa 32000 33aaa 34aaa 35aaa 36aaa 37aaa... (1 Reply)
I have this filename "RBD_EXTRACT_a3468_d20131118.tar.gz" and I would like print out the "yyyymmdd" only. I use this command below, but if different command like cut or print....etc. Thanks
ls RBD_EXTRACT* | sed 's/.*\(........\).tar.gz$/\1/' > test.txt (9 Replies)
Discussion started by: dotran
9 Replies
LEARN ABOUT REDHAT
pdl::state
State(3) User Contributed Perl Documentation State(3)NAME
State - A package to keep track of plotting commands
SYNOPSIS
use PDL::Graphics::State;
DESCRIPTION
This is a very simple, at present almost trivial, package to keep track of the current set of plotting commands.
USAGE
You create a new object by calling the "new" operator
$state = PDL::Graphics::State->new();
Then for each new command you call "add" on this object so that for a call to "line" of the form
line $x, $y, $opt;
the call to "add" would be like
$state->add(&line, 'line', [$x, $y], $opt);
which is stored internally as:
[&line, 'line', [$x, $y], $opt]
The state can later be extracted using "get" which returns the state object which is an array of anonymous arrays like the one above where
the first object is a reference to the function, the second an anomymous array of arguments to the function and finally an anonymous hash
with options to the command.
If you know the order in which you inserted commands they can be removed by calling "remove" with the number in the stack. No further
interaction is implmented except "clear" which clears the stack and "copy" which returns a "deep" copy of the state.
AUTHOR
Jarle Brinchmann (jarle@astro.ox.ac.uk) after some prodding by Karl Glazebrook.
All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For
details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be
included in the file.
perl v5.8.0 2001-09-26 State(3)