Search Results

Search: Posts Made By: Jotne
1,613
Posted By Jotne
@Scrutinizer Updated my post. PS your does...
@Scrutinizer
Updated my post.

PS your does not handle this:
|ABCD|EFGH|IJKL|MNOP
ABCD|EF\|GH|IJKL|
1,613
Posted By Jotne
Another awk awk -F\| '{gsub(/\\\|/,"_");for...
Another awk
awk -F\| '{gsub(/\\\|/,"_");for (i=/^\|/?2:1;i<=(/\|$/?NF-1:NF);i++) $i="\""$i"\"";gsub(/_/,"|")}1' OFS=\| file
|"ABCD"|"EFGH"|"IJKL"|"MNOP"
|"ABCD"|"EF|GH"|"IJKL"|"MNOP"
1,508
Posted By Jotne
Not a quick and short solution, but it works :) ...
Not a quick and short solution, but it works :)
I see that you store the number of spaces in an array, and then add i back.
1,508
Posted By Jotne
Update a field using awk and keep the formatting.
Look at this simple example.
echo " 2 4 6" | awk '{$2+=3;$3-=1}1'
2 7 5

Is there a simple way to update a field and at the same time keep the formatting?

I would like to get it like this
...
9,806
Posted By Jotne
Try this, just to remove the escape codes. awk...
Try this, just to remove the escape codes.
awk '{gsub(/\^\[\[[0-9]*;*[0-9]*(G\[|m]*)/,x)}1' file
9,806
Posted By Jotne
cat file Bringing up loopback interface: ...
cat file
Bringing up loopback interface: ^[[60G[^[[0;32m OK ^[[0;39m]^M^MŽ
19 Bringing up interface eth0: ^[[60G[^[[0;32m OK ^[[0;39m]^M^MŽ
20 Starting portreserve: ^[[60G[^[[0;32m OK ...
9,806
Posted By Jotne
Try some like this: awk...
Try some like this:
awk '{gsub(/\^M|\^\[\[[0-9]*G\[\^\[\[0;32m|\^\[\[0;39m\]/,x)}1' file
1,704
Posted By Jotne
Some like this? cat file 54324 13413 ...
Some like this?

cat file
54324
13413
11666
11777
11888
35635
45674
0666


awk '!/(0|11)(666|777|888)/' file
54324
13413
35635
45674
2,848
Posted By Jotne
You can make a crontab running every day, and...
You can make a crontab running every day, and then test if its the second day on mont, like this:
20 0 * * * [[ $(date +%d) -eq 2 ]] && Your script here
It will then only run on date 2 in the month...
1,641
Posted By Jotne
@R.Sing Will not work, sine this is just an...
@R.Sing
Will not work, sine this is just an example text and it will change.
One static is the :
1,641
Posted By Jotne
Thanks Corona, but hostname is missing. ...
Thanks Corona, but hostname is missing.

Another awk
awk '{gsub(/[a-zA-Z]+[0-9]+/,"\n&");gsub(/:|^\n/,x)}1' <<< "$var1"
abc001 text goes here
yyy003 text goes here
uuuu004 text goes here
^/n...
1,641
Posted By Jotne
Change one line to multiple
I did help some at another forum to change one line to multiple lines.
var1="abc001: text goes here yyy003: text goes here uuuu004: text goes here"
Running this awk, gives correct result, but its...
2,490
Posted By Jotne
I am to :) After finding it out I have examined...
I am to :)
After finding it out I have examined it some and found out that its not obscure at all.
It just standard brace expansion

Just look at
echo 1{a,b}
1a 1b
so when removing a and b, it...
2,490
Posted By Jotne
This was what I ask for. How to shorten file...
This was what I ask for. How to shorten file file to some shorter.
An file{,} is the answer.
2,490
Posted By Jotne
Found it after reading some hundreds of post {,}:...
Found it after reading some hundreds of post {,}:
awk 'FNR==NR {a[$1]++;next} ($2 in a) {print $2}' file file
is the same as
awk 'FNR==NR {a[$1]++;next} ($2 in a) {print $2}' file{,}


awk...
2,490
Posted By Jotne
Ok. I have seen it used, so I have to search.
Ok. I have seen it used, so I have to search.
2,490
Posted By Jotne
I just what to use the same file multiple times...
I just what to use the same file multiple times and write it once.

Example.
awk 'code' file file file file
This awk reads file 4 times and do some with the data.
I would like
awk 'code' 4xfile...
2,490
Posted By Jotne
@Corona688 This does not work, it gives me: ...
@Corona688
This does not work, it gives me:
awk 'FNR==NR {a[$1]++;next} ($2 in a) {print $2}' 2&file
[1] 7183
awk: cmd. line:1: fatal: cannot open file `2' for reading (No such file or directory)...
2,490
Posted By Jotne
Multiple file input
Once a time, I did see a way to multiply a file input in bash, but have forgotten how it was done.

Eks.
awk 'FNR==NR {a[$1]++;next} ($2 in a) {print $2}' file file
Here you need file two times....
1,805
Posted By Jotne
I guess its the strftime command It may be...
I guess its the strftime command
It may be replaced by some like this:
h=int($0/3600);m=int(($0-h*3600)/60);s=($0-h*3600-m*60);printf "%02d:%02d:%02d\n",h,m,s
1,805
Posted By Jotne
Another variation awk ' {split($2,a,":|,") ...
Another variation
awk '
{split($2,a,":|,")
t=a[1]*3600+a[2]*60+a[3]+a[4]/1000
$0=$1 FS sprintf ("%.3f\n",t)}

NR==1 {f=$1
t1=$2}
f!=$1 {x=$2
split(l,b," ")
t=b[2]-t1...
1,744
Posted By Jotne
Server 1 Ubuntu 12.04.3 LTS Server 2 Ubuntu...
Server 1 Ubuntu 12.04.3 LTS

Server 2 Ubuntu 12.04.2 LTS

File was created with exact same keystroke.

But for some reason I am not able to recreate the error.
So I have learned a new command...
1,744
Posted By Jotne
What type of configuration files? File is not...
What type of configuration files?
File is not uploaded, its created using nano via SSH
1,744
Posted By Jotne
You are correctly. :) Why does one server add...
You are correctly. :)
Why does one server add the \r but not the other.
I do the same on both server, using nano to create a file.
When I do test again, I am not able to reproduce the problem.
1,744
Posted By Jotne
Strange behavior on one of my server
I am not sure what is wrong, but I have some strange behavior when printing things out.

I do create a file with only one word test, no space, no new line etc.

nano file<enter>
test<ctrl...
Showing results 1 to 25 of 500

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