Search Results

Search: Posts Made By: A-V
2,561
Posted By RudiC
Not sure if this works for you: replace gsub...
Not sure if this works for you: replace gsub (/[ "}]*/, _) with gsub (/[ \r"}]*/, _). Be aware that the space in the search pattern is a <space> plus a <TAB> char!
2,561
Posted By RudiC
Which is an indicator for an Non-*nix-text,...
Which is an indicator for an Non-*nix-text, probably created by an MS application. Try - if available - dos2unix to convert your input file. Other means have been published in these fora as well.
2,561
Posted By RudiC
Not sure I understand your problem. If the...
Not sure I understand your problem. If the original file still exists, tryawk '/gender/ {gsub (/[ "}]*/, _); T = $2 $6; sub ("data", _, T); print "echo mv " T " " $6}' FS="[:,]" file | sh
mv...
2,561
Posted By RudiC
Howsoever, tryawk '/gender/ {gsub (/[ ...
Howsoever, tryawk '/gender/ {gsub (/[ "}]*/, _); T = $2 $6; sub ("data", _, T); print "echo mv " $6 " " T}' FS="[:,]" file | sh
mv data1 f1
mv data2 f2
mv data3 m3

Remove the "echo" if...
2,561
Posted By RudiC
Any attempt/idea/thought from your side?
Any attempt/idea/thought from your side?
1,962
Posted By Akshay Hegde
I used files from dir1 as reference since you...
I used files from dir1 as reference since you said same number of files with exactly same names, $i is file from dir1 and $file is file from dir2 to understand clearly, better you insert below line...
1,962
Posted By Akshay Hegde
[akshay@localhost tmp]$ cat test.sh ...
[akshay@localhost tmp]$ cat test.sh
#!/usr/bin/env bash

dir1="/tmp/test1/*.txt"
dir2="/tmp/test2"
output="/tmp/new"


mkdir -p $output

for i in $dir1; do

filename=${i##*/}
...
1,243
Posted By vgersh99
# set input FieldSeparator (FS) to , # set the...
# set input FieldSeparator (FS) to ,
# set the value to be be subtracted to 1 and assigned it to the internal awk variable s
awk -F, -v s=1 '
# for each record/line, execute block within {}
{...
1,243
Posted By vgersh99
awk -F, -v s=1 '{for (i=1;i<=NF;i++) if($i>=s)...
awk -F, -v s=1 '{for (i=1;i<=NF;i++) if($i>=s) $i-=s}1' OFS=, myFile
1,735
Posted By Don Cragun
With that input, we're seeing the output you seem...
With that input, we're seeing the output you seem to want.
Please post the output from the command:
od -bc file
where file is the input file you fed to either of the awk scripts provided by...
1,735
Posted By RudiC
Both proposals deliver the desired output, not...
Both proposals deliver the desired output, not the errorneous one you posted. Are you sure there's no hidden control chars in the input file? Did yo run the codes exactly as posted?
1,735
Posted By Akshay Hegde
Bit simplified version of vgersh99's solution ...
Bit simplified version of vgersh99's solution

$ awk -F, '{for(i=1; i<=NF; i++)$i=split($i,a," ")}1' OFS="," file
1,2,3
1,3,1
1,735
Posted By vgersh99
awk -F, '{for(i=1;i<=NF;i++) printf("%d%s",...
awk -F, '{for(i=1;i<=NF;i++) printf("%d%s", split($i,a, " "), (i==NF)?ORS:OFS)}' OFS=',' myFile
1,316
Posted By jim mcnamara
Your script appears to have issues to em. ...
Your script appears to have issues to em.

What follows is what your script does, which is probably not what you intended.

mkdir result/$doc/02-data
-> create a new empty...
2,142
Posted By drl
Hi. I like the solution of radoulov. I also...
Hi.

I like the solution of radoulov. I also like to break tasks down into manageable steps. One way to do that is to use code that packages up common tasks. A source for that is the missing...
2,142
Posted By radoulov
If Perl is acceptable: perl -F, -lane' push...
If Perl is acceptable:
perl -F, -lane'
push @d, [@F];
END {
$, = ",";
for $i (0..$#F) {
push @o, [sort { $a <=> $b } map $d[$_][$i], 0..$#d]
}
for $i (0..$#d) {
...
2,142
Posted By Akshay Hegde
Hi A-V! I forgot to use -d, with paste...
Hi A-V!

I forgot to use -d, with paste command you can remove tr -s '\t' ',', and replace

final_cmd="paste $arg | tr -s '\t' ','"

with

final_cmd="paste -d, $arg" to simplify code.
2,142
Posted By Akshay Hegde
Try : #!/bin/ksh # Loop through files ...
Try :

#!/bin/ksh

# Loop through files
for file in *.csv; do

# counting fields from first line and assuming fields in remaining lines are equal to first line
field=$(awk -F, 'NR==1{print...
2,142
Posted By Akshay Hegde
Try : $ cat f 1,5,7 3,4,9 2,6,8 $...
Try :

$ cat f
1,5,7
3,4,9
2,6,8

$ paste <(cut -d, -f1 f | sort) <(cut -d, -f2 f | sort) <(cut -d, -f3 f | sort) | tr -s '\t' ','
1,4,7
2,5,8
3,6,9
1,107
Posted By blackrageous
This looks like you're just combining both files...
This looks like you're just combining both files and sorting them.
So if file x.x is one of the files and y.y the other, then,...

cat x.x y.y | sort
Please clarify.
2,608
Posted By Don Cragun
If you're sure you just want to delete the 1st...
If you're sure you just want to delete the 1st three bytes of a file:
dd ibs=1 skip=3 if=filename of=filename.new
2,608
Posted By Scrutinizer
Like RudiC says, it appears to be UTF-8 encoding...
Like RudiC says, it appears to be UTF-8 encoding with the first three bytes being the BOM 0xEF 0xBB 0xBF. So you could try removing those using:
tail -c+4 file > file.new

or

If you have GNU...
2,608
Posted By Perderabo
Try using the iconv program. That is the way I...
Try using the iconv program. That is the way I ever translate character sets. For example if I have utf-16 and I want ascii it is just:
iconv -f utf-16 -t ascii < input.file

Read the man page...
1,828
Posted By Yoda
Apply these changes: END { ...
Apply these changes:
END {
printf "\t"
for ( k in P )
printf "%s\t", k
printf "\tCount\n"

for (...
1,828
Posted By Yoda
The program will not work if you feed one input...
The program will not work if you feed one input file at a time using a for loop.

You could pass them all at once:

awk '
-- code --
' accept-all.txt People/*
Showing results 1 to 25 of 97

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