03-27-2012
Hi, they are two different thing (I added spaces for clarity in my post above to illustrate). && means AND and ++A[$0] means increase with 1 the value of array element which has the entire line ($0) as an index. If the value equals 2, which is the case the second time the same line is encountered, then perform the (sub) action in curly brackets..
The difference between A[$0] and A[$1,$2,$3,$4] is that in the first case all the spaces and/or tabs are included, so that lines need to be exactly equal for us to conclude that they are the same, if we compare them. In the second case only the fields themselves need to be equal (the spaces between the fields may vary)...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys, so I have another issue. Can I use sed to replace spaces in a string or variable with %20
I am having trouble with using curl on URL's containing spaces
Thanks! (12 Replies)
Discussion started by: tret
12 Replies
2. UNIX for Dummies Questions & Answers
HI
In my script, i am reading the input from the user and want to find the length of the string.
The input may contain leading spaces. Right now, when leading spaces are there, they are not counted.
Kindly help me
My script is like below. I am using the ksh.
#!/usr/bin/ksh
echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies
3. Shell Programming and Scripting
Hi
I have an XML file with strings XABCD, XEFGHX and XIJKLX. I would like to replace XABCDX with "This is the first string", XEFGHX with "This is the second string" and XIJKLX with "This is the third string".
What is the best way to implement this? Should I have a file with the data that is... (4 Replies)
Discussion started by: zmfcat1
4 Replies
4. Shell Programming and Scripting
Hi,
i call my shell like:
my_shell "my project name"
my script:
#!/bin/bash -vx
projectname=$1
sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp
cp temp test_config_doxy
the following error occurres:
sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies
5. Shell Programming and Scripting
Hi, I'm very new to shell scripting and have searched google and this forum for quite some time now.
I have the following in my xml file:
<recipients>
<member>value1</member>
</recipients>
I need to find a string <recipients> that follows with a new-line and bunch of spaces and... (5 Replies)
Discussion started by: mgharios
5 Replies
6. Shell Programming and Scripting
Dear Friends,
I have a flat file from which I want to remove single "space". And, wherever two spaces are provided it should replace it by only one space.
E.g.
I have
N A T I O N A L E D U C A T I O N F O R O R G AN I S A T I ON S
I want
NATIONAL EDUCATION FOR ORGANISATIONS
Please... (5 Replies)
Discussion started by: anushree.a
5 Replies
7. Shell Programming and Scripting
Hi Guys
file:///C:/DOCUME%7E1/c104058/LOCALS%7E1/Temp/moz-screenshot.pngsed 's///g' /source/filename.txt > /destination/filename.txt
The above code deletes the characters which are not A-Z, a-z and 0-9, but I wanted to replace it with space without deleting them.
Any help is... (2 Replies)
Discussion started by: gowrishankar05
2 Replies
8. Shell Programming and Scripting
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies
9. Shell Programming and Scripting
Hi all,
I wanted to find and replace an email id from entire directory structure on a Linux server. I found that find . -type f -print0 | xargs -0 sed -i 's/abc@yahoo.com/xyz@gmail.com/g' would do it perfectly.
But my search criteria has extended and now I want to search for a string1 like... (2 Replies)
Discussion started by: pat_pramod
2 Replies
10. UNIX for Dummies Questions & Answers
I am trying to replace the string in position 26 through 35 of the data file with 10 spaces and I want the remaining file to stay as is, the record length is over 900 characters? I am trying to use the AWK and substr but I am not getting it formatted correctly.
Before... (6 Replies)
Discussion started by: fnwine1500
6 Replies
LEARN ABOUT OPENSOLARIS
fspec
fspec(4) File Formats fspec(4)
NAME
fspec - format specification in text files
DESCRIPTION
It is sometimes convenient to maintain text files on the system with non-standard tabs, (tabs that are not set at every eighth column).
Such files must generally be converted to a standard format, frequently by replacing all tabs with the appropriate number of spaces, before
they can be processed by system commands. A format specification occurring in the first line of a text file specifies how tabs are to be
expanded in the remainder of the file.
A format specification consists of a sequence of parameters separated by blanks and surrounded by the brackets <: and :>. Each parameter
consists of a keyletter, possibly followed immediately by a value. The following parameters are recognized:
ttabs The t parameter specifies the tab settings for the file. The value of tabs must be one of the following:
o A list of column numbers separated by commas, indicating tabs set at the specified columns.
o A '-' followed immediately by an integer n, indicating tabs at intervals of n columns.
o A '-' followed by the name of a ``canned'' tab specification.
Standard tabs are specified by t-8, or equivalently, t1,9,17,25, etc. The canned tabs that are recognized are defined by the
tabs(1) command.
ssize The s parameter specifies a maximum line size. The value of size must be an integer. Size checking is performed after tabs have
been expanded, but before the margin is prepended.
mmargin The m parameter specifies a number of spaces to be prepended to each line. The value of margin must be an integer.
d The d parameter takes no value. Its presence indicates that the line containing the format specification is to be deleted from
the converted file.
e The e parameter takes no value. Its presence indicates that the current format is to prevail only until another format specifi-
cation is encountered in the file.
Default values, which are assumed for parameters not supplied, are t-8 and m0. If the s parameter is not specified, no size checking is
performed. If the first line of a file does not contain a format specification, the above defaults are assumed for the entire file. The
following is an example of a line containing a format specification:
* <:t5,10,15 s72:> *
If a format specification can be disguised as a comment, it is not necessary to code the d parameter.
SEE ALSO
ed(1), newform(1), tabs(1)
SunOS 5.11 3 Jul 1990 fspec(4)