Search Results

Search: Posts Made By: sgruenwald
1,362
Posted By sgruenwald
So basically what the code means: sort lines of...
So basically what the code means: sort lines of mpcashqc.xtr by the third field with "|" as separator. and pipe it to awk. Awk takes it (again with "|" field separator) and makes a sum of field 3...
3,502
Posted By sgruenwald
Thanks ctsgnb, I have never tried your method but...
Thanks ctsgnb, I have never tried your method but I will now.
3,502
Posted By sgruenwald
If you have the data comma separated and want to...
If you have the data comma separated and want to sort the second column:

$ sort -t, file1 -k 2,2 | uniq -u >file2
3,185
Posted By sgruenwald
You can create directories, subdirectories and...
You can create directories, subdirectories and subsubdirectories in one swoop with the mkdir -p command (brace expansions) using the bash shell (3.0 or higher!).

mkdir -p...
8,558
Posted By sgruenwald
Here is a solution using sed
sed 's/\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/\4 \5 \2 \3/' file_in
root lag book day
boot tag look pay
moot sag took may


You can use >file_out to write the results back to a file

sed...
1,605
Posted By sgruenwald
regex="abx"; for file in *.cvs; do awk -v...
regex="abx"; for file in *.cvs; do awk -v str=$regex '{if ($6==str) print $1,$3,$4}' $file >$file.out; done
5,349
Posted By sgruenwald
Shell script: ls -R | grep ":" | sed -e...
Shell script:

ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
4,599
Posted By sgruenwald
Here is an alternative way using awk and sed -...
Here is an alternative way using awk and sed - changing ALL the *.pdf files made up in a similar way (double digit _ double digit _ double digit.pdf) in all the subdirectories from your current one...
1,723
Posted By sgruenwald
Zam, in ksh this works just fine: echo...
Zam, in ksh this works just fine:

echo 'dddd$dddd' | tr "$" " "
dddd dddd

-Stefan
5,072
Posted By sgruenwald
I am not sure whether anybody mentioned to you...
I am not sure whether anybody mentioned to you but when you use a variable under 'awk' that is originally a string (because you piped it as a string from somewhere or you used it as a string in the...
Forum: Programming 03-29-2011
1,835
Posted By sgruenwald
I still don't get it. Could you show an example...
I still don't get it. Could you show an example of an output you would like to have? Also, why is the 1 second line repeated?
Forum: Web Development 03-29-2011
37,482
Posted By sgruenwald
Firefox 4.0 just came out. Works great!
Firefox 4.0 just came out. Works great!
886
Posted By sgruenwald
Strange. I just tried it on my system, which is: ...
Strange. I just tried it on my system, which is:

BASH_VERSINFO=([0]="2" [1]="05b" [2]="0" [3]="1" [4]="release" [5]="powerpc-apple-darwin7.0")
BASH_VERSION='2.05b.0(1)-release'

It works fine....
875
Posted By sgruenwald
Please follow this URL for info provided by Neo: ...
Please follow this URL for info provided by Neo:

https://www.unix.com/members-only/111844-current-bits-system-awards-alpha-release.html
16,032
Posted By sgruenwald
Similar solution - piped through tr
sed 's_\([0-9][a-zA-Z]\)*\([0-9][0-9]*\)_\1\2\^\2_g' <chars | tr '^' '\t'
C21 21
F231 231
H42 42
1C10 10
1F113 113


If sed doesn't take the \t as a tab then pipe it through tr...
3,938
Posted By sgruenwald
awk -v x=0 '{if ($1==name) x=$2} END {print name,...
awk -v x=0 '{if ($1==name) x=$2} END {print name, x}' name=Mary list.txt
Mary 10
awk -v x=0 '{if ($1==name) x=$2} END {print name, x}' name=Tom list.txt
Tom 0
2,046
Posted By sgruenwald
Pull specific lines from long file based on formula
For people who want to pull a number of lines from a long file using a specific formula

n (number of iterations in a loop)
a (offset number)
b (stretch factor)

example with n {1..100}

for...
2,996
Posted By sgruenwald
Some confused me too. Very interesting questions.
Some confused me too. Very interesting questions.
3,938
Posted By sgruenwald
grep 'Marcus' list.txt | awk '{print $2}; END {...
grep 'Marcus' list.txt | awk '{print $2}; END { if (!found) print "0" }' It returns "0" but it also returns "0" on other names that are not Mary, when you search for Mary. Is that what you wanted?
2,073
Posted By sgruenwald
How consistent is the header and the data? Please...
How consistent is the header and the data? Please give an example. Or, is it always one single line of header and two lines of data throughout the whole file? Please explain.
8,843
Posted By sgruenwald
awk '{a[int($2/r)]++}END{for(i in a) print "["...
awk '{a[int($2/r)]++}END{for(i in a) print "[" i*r "-" (i*r)+r-1 "] " a[i]}' r=5 myfile
3,457
Posted By sgruenwald
Hi Pawan: Maybe you should concatenate your...
Hi Pawan:

Maybe you should concatenate your DNA part. Use this code:
head -n +1 <dna >dna_concat; tail -n +2 <dna | tr -d '\n' >>dna_concat

It reads in the description/name of your code on the...
3,457
Posted By sgruenwald
Hi Corona - nice code, but Pawan needs these...
Hi Corona - nice code, but Pawan needs these lines concatenated, since this is DNA. Meaning, it is actually one long SINGLE string of information, he just broke it into 3 lines. So, if "GAT" is...
2,186
Posted By sgruenwald
You can delete the filename extensions easily by...
You can delete the filename extensions easily by doing:
for i in *.txt; do mv $i ${i%%.*}; done

If you want to put some file extensions back to files, copy the files into their own directory (for...
3,073
Posted By sgruenwald
This should do it: tr '\r\n' '|' <in | sed...
This should do it: tr '\r\n' '|' <in | sed 's/||/$/g' | tr '$' '\n'

You can pipe it to awk (for example: awk -F"|" '{print$0}' see below) and prove that it has the field separator "|" and the...
Showing results 1 to 25 of 35

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