Search Results

Search: Posts Made By: anurag.singh
4,963
Posted By anurag.singh
awk -F'(>|<)' '/value1/,/value2/...
awk -F'(>|<)' '/value1/,/value2/ {if($2=="value1") v1=$3; else a[v1," ",$3]++}END{for (i in a) print i}' inputXML

For above input, output is:

xyx 123
568 zzzzz
20,289
Posted By anurag.singh
find -name file1.txt -a -name file2.txt this...
find -name file1.txt -a -name file2.txt

this will try to find a file with name "file1.txt" AND "file2.txt". No match, so no result.
For your need, may be you can use Logical OR and count the...
Forum: Red Hat 01-06-2011
1,143
Posted By anurag.singh
chsh -s /bin/sh news 2>&1 | awk '{print...
chsh -s /bin/sh news 2>&1 | awk '{print $5}'
2,351
Posted By anurag.singh
Assuming every record will have 6 fields: ...
Assuming every record will have 6 fields:

awk -F, 'NR==FNR{a[$1]=$2;b[$1]=$3;c[$1]=$4;d[$1]=$5;e[$1]=$6;next;}{if(a[$1]) print $1", "$2/a[$1]", "$3/b[$1]", "$4/c[$1]", "$5/d[$1]", "$6/e[$1]; else...
3,078
Posted By anurag.singh
1. $1 != "X" == >> $1 is 1st field of every...
1. $1 != "X" == >> $1 is 1st field of every record, This check ensures that we should not process 1st record in inputFIle, The Header Record (X , ID , Date, Time, Y
). But this check is not...
4,174
Posted By anurag.singh
depth=$(awk 'BEGIN{FS="(\(|\))"} /CURDEPTH/{if($2...
depth=$(awk 'BEGIN{FS="(\(|\))"} /CURDEPTH/{if($2 > 10){print $2;p=1;exit}}END{if(!p) print 0}' test1.txt)
if [ $depth -gt 10 ]; then
mailx -s "Your Mail Subject" EMAIL_ID < mail_body_file
fi
49,718
Posted By anurag.singh
Your current output and desired output look same....
Your current output and desired output look same.
Also you didn't mention the inputs completely. Pls mention sample of each file content, expected out, current output, the command you are tried.
15,254
Posted By anurag.singh
always post exact input (or most generalized...
always post exact input (or most generalized one). Try following:
echo "**abcd **1234** efgh**" | sed "s/\*\*/'''/2;s/\*\*/'''/2"OR
echo "**abcd **1234** efgh**" | sed...
1,483
Posted By anurag.singh
ab=$(echo $dirk | awk '{for(i=1;i<=NF;i++)...
ab=$(echo $dirk | awk '{for(i=1;i<=NF;i++) if(index($i,"ab")){print $i;exit;}}')
35,128
Posted By anurag.singh
Execute script as: a.sh 20110114 "b c d"And...
Execute script as:
a.sh 20110114 "b c d"And pass 2nd argument in quotes to sql proc:
<sql_proc> "$2"
But not very sure about sql procedure. If above doesn't work, then you may do following:...
2,233
Posted By anurag.singh
printf("%s:%02d\n",$1,$2-4) 1st argument to...
printf("%s:%02d\n",$1,$2-4)

1st argument to printf is the format. %s to print $1 as string, %d is to print as integer where 02 is to padd ZERO on left if ($2-4) width is less than 2.
For more...
3,764
Posted By anurag.singh
Your initial input is different than this one. ...
Your initial input is different than this one.
Following shouild work:
awk -F\" '/Cell id/{if(!a[$2]) cnt++;a[$2]++;next}END{print cnt}' gen_cell_orig_001.dsx
3,513
Posted By anurag.singh
If condition should be: if [ $# -ne 2 ]
If condition should be:

if [ $# -ne 2 ]
2,887
Posted By anurag.singh
exec should be better than xargs.
exec should be better than xargs.
1,774
Posted By anurag.singh
awk '/N1\*PR/,/N1\*PE/' inputFile | grep -c...
awk '/N1\*PR/,/N1\*PE/' inputFile | grep -c "PER"
10,162
Posted By anurag.singh
#!/usr/bin/ksh FILE="$1" cat $FILE| cut -d'\'...
#!/usr/bin/ksh
FILE="$1"
cat $FILE| cut -d'\' -f2- | sed 's/EMEA//g;s/\\//g;s/,//g'
4,992
Posted By anurag.singh
sed 's/<int>\([0-9]*\)/<int>{rid1}/2' inputFile ...
sed 's/<int>\([0-9]*\)/<int>{rid1}/2' inputFile

OR

sed 's/[0-9][0-9]*/{rid1}/2' inputFile
1,272
Posted By anurag.singh
There is a EXAMPLES section in man page of comm. ...
There is a EXAMPLES section in man page of comm.
That has exactly what you want. Get common data for 3 files.
Idea is, pipe the output of 2 files to the 3rd file.
Pls try. If you get further...
1,015
Posted By anurag.singh
For input vst_qp_vds_Fido_VT0220101029.txt ...
For input
vst_qp_vds_Fido_VT0220101029.txt
Active

vst_fact_cms_purchase_trans_20101015.dat
Active

vst_soc_activity_detail2_VT0120101028.dat
Active

vst_fact_api_cdr_VT0320101029.csv...
13,573
Posted By anurag.singh
Depending on how exactly you want to edit: If...
Depending on how exactly you want to edit:
If you want to change all line having "Chocolate:5:5" to "Chocolate:5:10"

sed 's/Chocolate:5:5/Chocolate:5:10/'


OR change all lines "Banana:33:3"...
4,669
Posted By anurag.singh
post #3: (by myself) Set field separator to...
post #3: (by myself)
Set field separator to pipe character i.e. |
If current file read is "from_file", store each record ($0) in array a indexed as 1dt field in that record, and move to next line...
4,478
Posted By anurag.singh
first line of a file but not the first line? ...
first line of a file but not the first line?
didn't get you.
OK.. By looking at header (How do I read a file but not the first line?)

awk 'NR>1' inputFile

OR

sed -n '2,$p' inputFile
3,769
Posted By anurag.singh
sed 's/^1$//' inputFile OR awk...
sed 's/^1$//' inputFile

OR

awk '{if(0+$0 ==1) $0="";}1' inputFile
4,547
Posted By anurag.singh
From the input given by you in post #1, I suppose...
From the input given by you in post #1, I suppose output will be:

Series: XYZ
Manufacturer: ...
Software Version: ...
Year made: ...
Series: ABC
Manufacturer: ...
Software Version: ...
Year...
1,099
Posted By anurag.singh
sed 's/pro[ ]/pro\ /g' inputFile
sed 's/pro[ ]/pro\
/g' inputFile
Showing results 1 to 25 of 95

 
All times are GMT -4. The time now is 01:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy