02-01-2007
Only awk is working fine. However, while assigning the same to variable, it is not working.
My Sample Inputfile is as shown below:
MyAdd1 MyAdd2 MyAdd3 MyAdd4 MyAdd5 Sachin Tendulkar 222 222-2222 11111111111111A0000111122223333XYX
YourAdd1 YourAdd2 YourAdd3 YourAdd4 YourAdd5 Rahul Dravid 111 121-5555 22222222222222B0123456789123456XYX
(In above example, spaces are getting truncated in this forum)
Basically, position 233-240 denotes account number. Also, by substring, I am trying to extract 241 character.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Is there any way to something like this?:
variable=printf("%30s",var1)
Thx. (2 Replies)
Discussion started by: Klashxx
2 Replies
2. Shell Programming and Scripting
Dear Friends
I have text file as like below,
AAAAA|BHBHBH|VERYSMART
AAAAA| KKKKKK|GOOD
BBBBBB|JJJJJJJ|VERYGOOD
CCCCC|HJHJHJ|BETTER
CCCCC|UUUUU|GOOD
i need to split into seperate files based on column 1 like as below
AAAAA.TXT contains
--------------------
BHBHBH.VERYSMART... (4 Replies)
Discussion started by: HAA
4 Replies
3. Shell Programming and Scripting
#!/bin/sh
#
##
MYSTRING = `awk '/myApp.app/' /Users/$USER/Library/Preferences/loginwindow.plist`
if
then
echo String not found
defaults write /Users/$USER/Library/Preferences/loginwindow AutoLaunchedApplicationDictionary -dict-add -string Hide -bool YES -string Path -string... (9 Replies)
Discussion started by: dedmakar
9 Replies
4. Shell Programming and Scripting
I want to filter 2nd column = 2 using awk
$ cat t
1 2
2 4
$ VAR=2
#variable worked in print
$ cat t | awk -v ID=$VAR ' { print ID}'
2
2
# but variable didn't work in awk filter
$ cat t | awk -v ID=$VAR '$2~/ID/ { print $0}' (2 Replies)
Discussion started by: honglus
2 Replies
5. Shell Programming and Scripting
Dear All,
we have a command output which looks like :
Total 200 queues in 30000 Kbytes
and we're going to get "200" and "30000" for further process. currently, i'm using :
numA=echo $OUTPUT | awk '{print $2}'
numB=echo $OUTPUT | awk '{print $5}'
my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies
6. Shell Programming and Scripting
hi i want to find the size of a folder and assign it to a variable and then compare if it is greater than 1 gb.
i am doin this script, but it is throwing error....
#!/bin/ksh
cd . | du -s | size = awk '{print $1}'
if size >= 112000
then
echo size high
fi
ERROR : (4 Replies)
Discussion started by: Nithz
4 Replies
7. Shell Programming and Scripting
I launch 'netstat -a', if string 'ESTABLISHED' found, then VAR=1
#!/bin/bash
VAR=0;
netstat -a | awk '$6 ~ /ESTABLISHED/ {VAR=1}'
I cannot find the right syntax.
thanx guys! (3 Replies)
Discussion started by: arpagon
3 Replies
8. UNIX for Beginners Questions & Answers
I have the following script, and I want to assign the output ($10 and $5) from awk to N and L:
grdinfo data.grd | awk '{print $10,$5}'| read N L
output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies
9. UNIX for Beginners Questions & Answers
Hi,
I am trying to assign a value using below command and it is assigning the command to the variable not the output of the command?
out_value="echo $0 | cut -c 9-11";
How can i assign the output to the variable instead of whole command?
This is inside my awk script (7 Replies)
Discussion started by: bhagya123
7 Replies
10. Shell Programming and Scripting
Hi Gurus,
I have a script which assign awk output to shell variable. current it uses two awk command to assign value to two variables. I want to use one command to assign two values to two variables. I tried the code, but it does't work. kindly provide your suggestion.
current code... (2 Replies)
Discussion started by: green_k
2 Replies
SUBST(1) General Commands Manual SUBST(1)
NAME
subst - substitute definitions into file(s)
SYNOPSIS
subst [ -e editor ] -f substitutions victim ...
DESCRIPTION
Subst makes substitutions into files, in a way that is suitable for customizing software to local conditions. Each victim file is altered
according to the contents of the substitutions file.
The substitutions file contains one line per substitution. A line consists of two fields separated by one or more tabs. The first field
is the name of the substitution, the second is the value. Neither should contain the character `#', and use of text-editor metacharacters
like `&' and `' is also unwise; the name in particular is best restricted to be alphanumeric. A line starting with `#' is a comment and
is ignored.
In the victims, each line on which a substitution is to be made (a target line) must be preceded by a prototype line. The prototype line
should be delimited in such a way that it will be taken as a comment by whatever program processes the file later. The prototype line must
contain a ``prototype'' of the target line bracketed by `=()<' and `>()='; everything else on the prototype line is ignored. Subst
extracts the prototype, changes all instances of substitution names bracketed by `@<' and `>@' to their values, and then replaces the tar-
get line with the result.
OPTIONS
-e Substitutions are done using the sed(1) editor, which must be found in either the /bin or /usr/bin directories. To specify a dif-
ferent executable, use the ``-e'' flag.
EXAMPLE
If the substitutions file is
FIRST 111
SECOND 222
and the victim file is
x = 2;
/* =()<y = @<FIRST>@ + @<SECOND>@;>()= */
y = 88 + 99;
z = 5;
then ``subst -f substitutions victim'' changes victim to:
x = 2;
/* =()<y = @<FIRST>@ + @<SECOND>@;>()= */
y = 111 + 222;
z = 5;
FILES
victimdir/substtmp.new new version being built
victimdir/substtmp.old old version during renaming
SEE ALSO
sed(1)
DIAGNOSTICS
Complains and halts if it is unable to create its temporary files or if they already exist.
HISTORY
Written at U of Toronto by Henry Spencer.
Rich $alz added the ``-e'' flag July, 1991.
BUGS
When creating a file to be substed, it's easy to forget to insert a dummy target line after a prototype line; if you forget, subst ends up
deleting whichever line did in fact follow the prototype line.
25 Feb 1990 SUBST(1)