Search Results

Search: Posts Made By: 100bees
1,527
Posted By blackrageous
This seems to be just a replace issue easily...
This seems to be just a replace issue easily handled by sed without the need for the power of awk.

The $ is the only character that needs to be quoted to prevent the system thinking a variable is...
3,099
Posted By bartus11
I think your input should...
I think your input should be:fruits,apple,20,fruits,mango,20,veg,carrot,12,veg,raddish,30
fruits,pinapple,10,fruits,orange,5,fruits,apple,20,Grains,wheat,100

---------- Post updated at 08:37 AM...
1,838
Posted By Don Cragun
In any version of ksh newer than November 16,...
In any version of ksh newer than November 16, 1988, you can also use:
for ((i=2; i<=6; i++))
do <statements>
done
Although not available in the original 1993 version of ksh, the:
for ctcol in...
1,838
Posted By balajesuri
From what I know, range expansion {2..6} is a...
From what I know, range expansion {2..6} is a part of modern bash shell's parameter expansion feature and not a feature of ksh.

An alternative that will work for sure (even in old bourne shells):...
7,797
Posted By summer_cherry
python
with open("a.txt") as f:
for line in f:
line=line.replace("\n","")
words=line.split(",")
words=[words[0]]+words[len(words)-2:]+words[1:len(words)-2]
print(",".join(words))
7,797
Posted By Franklin52
Another approach: awk -F, '{$1=$1 FS $(NF-1) FS...
Another approach:
awk -F, '{$1=$1 FS $(NF-1) FS $NF}NF=NF-2' OFS=, file
7,797
Posted By anbu23
$ sed "s/\([^,]*\)\(.*\)\(,[^,]*,.*\)$/\1\3\2/"...
$ sed "s/\([^,]*\)\(.*\)\(,[^,]*,.*\)$/\1\3\2/" file
a1,b1,b2,abc,jsd,fhf,fkk
a2,b3,c4,acb,dfg,ghj
a3,d4,d5,djf,wdjg,fkg,dff,ggk
7,797
Posted By pamu
awk -F,...
awk -F, '{A=$1","$(NF-1)","$NF;sub($(NF-1)","$NF,"");$1=A}1' OFS="," file
7,797
Posted By rajamadhavan
$ awk -F","...
$ awk -F"," '{i=$(NF-1);j=$NF;for(k=NF;k>=4;k--){$k=$(k-2);};$2=i;$3=j} {print $0}' aak
a1 b1 b2 abc jsd fhf fkk
a2 b3 c4 acb dfg ghj
a3 d4 d5 djf wdjg fkg dff ggk
4,630
Posted By Yoda
Here is an awk approach: awk ' { ...
Here is an awk approach:
awk '
{
for ( i = 1; i <= NF; i++ )
{
if ( $i == "LLL" && $( i + 1 ) == "SSS" )
...
34
80,130
Posted By ungalnanban
Vim tips and tricks
Vim Tips and Tricks


Save and quit



:w => Save [:w filename writes the content to the specified file from current file]

:q => Exit as long as there have been no changes

:q! =>...
Showing results 1 to 11 of 11

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