Search Results

Search: Posts Made By: anurag.singh
49,952
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,471
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,506
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,291
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:...
4,233
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
2,285
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,802
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
1,794
Posted By anurag.singh
awk '/N1\*PR/,/N1\*PE/' inputFile | grep -c...
awk '/N1\*PR/,/N1\*PE/' inputFile | grep -c "PER"
10,336
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'
3,578
Posted By anurag.singh
If condition should be: if [ $# -ne 2 ]
If condition should be:

if [ $# -ne 2 ]
13,894
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"...
1,048
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...
4,507
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,803
Posted By anurag.singh
sed 's/^1$//' inputFile OR awk...
sed 's/^1$//' inputFile

OR

awk '{if(0+$0 ==1) $0="";}1' inputFile
1,123
Posted By anurag.singh
sed 's/pro[ ]/pro\ /g' inputFile
sed 's/pro[ ]/pro\
/g' inputFile
5,239
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
4,587
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...
4,713
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...
Forum: Red Hat 01-06-2011
1,151
Posted By anurag.singh
chsh -s /bin/sh news 2>&1 | awk '{print...
chsh -s /bin/sh news 2>&1 | awk '{print $5}'
1,276
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,276
Posted By anurag.singh
Look at man comm comm...
Look at man comm
comm (https://www.unix.com/man-page/POSIX/1/comm/)
2,928
Posted By anurag.singh
exec should be better than xargs.
exec should be better than xargs.
1,271
Posted By anurag.singh
Variables passed to expr (x or y) are not...
Variables passed to expr (x or y) are not initialized.
You are assigning values to x or y in if/else block, so depending on conditions, x/y may not be initialized.
Pls make sure you initilize x and...
2,310
Posted By anurag.singh
OR using sed: sed -n 's/^To: <\(.*\)>/\1/p'...
OR using sed:

sed -n 's/^To: <\(.*\)>/\1/p' email.txt
sed -n 's/^Subject: \(.*\)/\1/p' email.txt
2,728
Posted By anurag.singh
Assuming that ONLY 10th and 11th columns are...
Assuming that ONLY 10th and 11th columns are considered to decide duplicates (No other column check)

awk 'NR==FNR{a[$10"_"$11]++;next;}{if(a[$10"_"$11] < 2) print $0}' inputFile inputFile
Showing results 1 to 25 of 95

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