Search Results

Search: Posts Made By: IMPe
1,455
Posted By RudiC
Some sample always helps! Try (untested)awk 'NR>5...
Some sample always helps! Try (untested)awk 'NR>5 {sub(/^/, NR-5)} 1' file
1,455
Posted By RavinderSingh13
Hello IMPe, Request you to please always do...
Hello IMPe,

Request you to please always do show sample input and expected sample output too. If I understood correctly your requirement, could you please try following and let me know if that...
Forum: Debian 10-24-2015
4,372
Posted By RudiC
Downloading with what? Would it be worthwhile to...
Downloading with what? Would it be worthwhile to look into your browser's config?
1,322
Posted By Don Cragun
You might want to try this instead: #!/bin/bash...
You might want to try this instead:
#!/bin/bash
awk '
FNR == 1 {
close(fn)
seq = substr(FILENAME, 8, 3)
fn = "test" FILENAME ".txt"
printf("%-13s\n", seq) > fn
}
FNR == 8 || FNR == 10 ||...
1,322
Posted By Don Cragun
There are enough strange constructs in your...
There are enough strange constructs in your sample shell script that I am not at all sure what you are trying to do, what your input files look like, nor what your output file is supposed to look...
1,629
Posted By CarloM
What have you tried? awk 'FNR==8 || FNR==10 ||...
What have you tried?
awk 'FNR==8 || FNR==10 || (FNR>=13 && FNR<=250)' sample.txt
should work.
57,957
Posted By vgersh99
awk '{for(i = 1; i<=NF; i++);if(i != 1 && i != 4)...
awk '{for(i = 1; i<=NF; i++);if(i != 1 && i != 4) print($i)}' file.csv
57,957
Posted By Aia
Maybe? awk '{$1=$4=":"; gsub(/:,/, "")};1'...
Maybe?

awk '{$1=$4=":"; gsub(/:,/, "")};1' OFS=, FS=, file.csv
5,843
Posted By Scrutinizer
Hi, try: date --date="$(date +%Y%m15) 1 month...
Hi, try:
date --date="$(date +%Y%m15) 1 month ago" +%Y%m

This behavior occurs, because februari 30 does not exist. So it is best to use the middle of the month to calculate the previous month..
...
5,910
Posted By Corona688
What are the contents of file.tmp?
What are the contents of file.tmp?
5,910
Posted By RudiC
Try sth likeawk -F, '{for (i=4;i<=26;i++)...
Try sth likeawk -F, '{for (i=4;i<=26;i++) SUM[i]+=$i} END {for (i=4;i<=26;i++) print i, SUM[i]}' OFS="\t" file
5,910
Posted By Corona688
How about you tell us exactly what you are trying...
How about you tell us exactly what you are trying to do? I don't think your original solution was the most efficient, running awk once per line.
2,049
Posted By RudiC
As you are using awk anyhow, why don't you do the...
As you are using awk anyhow, why don't you do the maths and formatting all in one single awk script? Might be clearer, cleaner and easier to maintain.
2,384
Posted By ctsgnb
You can then go for : sed...
You can then go for :

sed 's!\(...\)\(...\)..!\2\1!' yourfileor (a little more "secure")
sed 's!\(../\)\(../\)..!\2\1!' yourfileNote that when you go from YYYY to YY you loose information and may...
2,384
Posted By ctsgnb
Could be done with simple sed statements like: ...
Could be done with simple sed statements like:
sed 's!\(..\)/\(..\)!\2/\1!' yourfile
orsed 's!\(...\)\(...\)!\2\1!' yourfile
2,384
Posted By CarloM
I suspect d[3] may actually be the rest of the...
I suspect d[3] may actually be the rest of the line. Try setting FS & OFS separately.
awk '{split($1,d,"/"); $1=d[2]"/"d[1]"/"(substr(d[3],3,2)); print}' FS=, OFS=, file
2,384
Posted By CarloM
"%2d/%02d/%02d,%s,%s,%s\n" is expecting 6...
"%2d/%02d/%02d,%s,%s,%s\n" is expecting 6 arguments, and you only have 4 (and 11 or 12 fields on the lines).

One way might be to use split rather than having multiple field separators:
awk...
4,202
Posted By ctsgnb
To keep the same formatting: sed 's;[:/];,;g'...
To keep the same formatting:
sed 's;[:/];,;g' yourfile | sort -t, -k 4,4 -k 2,3 -k 5,6 | sed 's/,/:/5;s:,:/:3;s:,:/:2'or move the YY at the beginning of the date so that the format will change into...
4,202
Posted By ctsgnb
A best practice is to use the YYYYMMDD format...
A best practice is to use the YYYYMMDD format (date '+%Y%m%d') for the date, so that further sorting are made easy.

Not that YYYY is better than YY because retaining only the 2 last digit suppose...
2,535
Posted By Corona688
The feature you are looking for is called a...
The feature you are looking for is called a backreference, you can quote parts of text inside \( \) and refer to them later with \1 \2 \3 ...

sed 's/:\([0-5]\)[1-5]:/:\10:/g' file.txt
2,535
Posted By disedorgue
Hi, try: sed -e 's/\(:[0-9]\)[1-9]:/\10:/'...
Hi, try:
sed -e 's/\(:[0-9]\)[1-9]:/\10:/' file.txt
Regards.

Edit: Too late :)

In Fact, no, @Corona688: [0-5] it's right but [1-5] ?
2,535
Posted By Corona688
Because that's what he had. I suspect we don't...
Because that's what he had. I suspect we don't completely know his requirements, maybe he wants to do rounding...
2,535
Posted By disedorgue
He said: allways to full ten-minutes :)
He said:
allways to full ten-minutes :)
2,535
Posted By Corona688
Yes... and then showed an example that matched...
Yes... and then showed an example that matched 1-5. Does he want to round down to ten minutes for low numbers, and up to ten minutes for high ones?

Being unsure, I showed him how backreferences...
2,049
Posted By Scrutinizer
Instead of "$T20-$T120", the proper syntax would...
Instead of "$T20-$T120", the proper syntax would be "$(( T20 - T120 ))"
--edit--
That should be $(echo "$T20 - $T120" | bc) since it is bash, not ksh93
Showing results 1 to 25 of 67

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