Search Results

Search: Posts Made By: kevintse
5,431
Posted By kevintse
awk '{printf("%.1f %s\n", 0.4*(NR-1), $0)}'...
awk '{printf("%.1f %s\n", 0.4*(NR-1), $0)}' infile
7,333
Posted By kevintse
Cool, you just changed the output record...
Cool, you just changed the output record separator accordingly.
I am just using the tools, while you are playing with the tools.
That was amazing!
7,333
Posted By kevintse
With awk, you can use: awk '{if(a!=""){a=a "\t"...
With awk, you can use:
awk '{if(a!=""){a=a "\t" $0}else{a=$0}} NR%12 == 0{print a; a=""}' infile

With perl, the code is a little bit more verbose.
perl -le 'while(<>){chomp;...
1,060
Posted By kevintse
This is really easy, use: find...
This is really easy, use:
find /home/*/public_html -name uploads -prune -o -name albums -prune -o -name "*.php" -print
12,201
Posted By kevintse
I didn't test the command, but it should be...
I didn't test the command, but it should be something like that.
2,974
Posted By kevintse
The most useful info for people here to help you...
The most useful info for people here to help you is input and desired output, otherwise it will take a long time for people to figure out what exactly you want before they start thinking of a...
1,526
Posted By kevintse
awk 'BEGIN{OFS="\t"} NR == FNR{a[$0]; next}...
awk 'BEGIN{OFS="\t"}
NR == FNR{a[$0]; next}
FNR == 1{ for(i=1;i<=NF;++i){if($i in a){a[$i]=i}} for(e in a){printf e OFS} printf ORS; next}
{for(i in a){printf $a[i] OFS} printf ORS}'...
5,936
Posted By kevintse
For detecting the server crash, you need some...
For detecting the server crash, you need some info from which to tell that, maybe from a log file generated by the JBoss server, you can setup a cron job to grep the log file regularly. After that,...
6,400
Posted By kevintse
awk 'NR>=3 && /red/' infile
awk 'NR>=3 && /red/' infile
6,770
Posted By kevintse
I assume the first row is the current date. awk...
I assume the first row is the current date.
awk 'BEGIN{"date +%m%d%Y" | getline first; print "1|" first} {if(NR>1){print "2|"$0}else{print "1|"$0} ++c}END{print "3|"c}' infile
1,354
Posted By kevintse
You need to elaborate on how your file names look...
You need to elaborate on how your file names look like, how the directories to which you want to put your files look like.

Otherwise, I can only come up with the following:
for file in `ls -1`;...
2,542
Posted By kevintse
perl:
perl:
3,705
Posted By kevintse
It is most likely that your HTML file has special...
It is most likely that your HTML file has special characters you should escape for mysql, like single-quotes, try escaping them by replacing each single-quote with triple-quotes.
5,035
Posted By kevintse
sed -i '$ i\<user username="'$user'"...
sed -i '$ i\<user username="'$user'" password="'$pword'" roles="'$roles'" />' input.txt

When $(last line) is used, </tomcat-users> is assumed to appear at the end of the file. and i that follows...
1,117
Posted By kevintse
You don't need to match the blank lines sed -n...
You don't need to match the blank lines
sed -n '/^11111$/,/^33333$/p' infile

If this is not what you want, post your real data and desired output.
1,117
Posted By kevintse
sed -n '1,4p' infile
sed -n '1,4p' infile
1,623
Posted By kevintse
I have no idea what that box type character is,...
I have no idea what that box type character is, it doesn't look like a newline character though.

You can use dump or xxd and find the hex representation of that character:
head -1 your_file |...
5,895
Posted By kevintse
You would likely use Regex rather than Wildcard...
You would likely use Regex rather than Wildcard when searching text in a file.
And 82M is far from being big enough and called a huge file.
1,973
Posted By kevintse
awk 'NR==FNR{a[$0]; next}$0 in a{++c}END{print...
awk 'NR==FNR{a[$0]; next}$0 in a{++c}END{print c}' file1 file2
1,623
Posted By kevintse
Yea, you can use sed: sed 's/$/\r/' infile >...
Yea, you can use sed:
sed 's/$/\r/' infile > dos.txt

BTW, when you use unix2dos, you don't do unix2dos file1.txt > file2.txt
you simply do
unix2dos file1.txt

unix2dos converts your files in...
742
Posted By kevintse
The preceding script can be rewritten a little...
The preceding script can be rewritten a little verbosely as the following:
awk -F, '$1=="ABC"&&($2=="XYZ"||$2=="DEF") {$6="This is a valid record"}1{print}' OFS="," infile
or
awk -F,...
1,496
Posted By kevintse
This question has been answered for many many...
This question has been answered for many many times.
https://www.unix.com/shell-programming-scripting/49369-replace-value-variable-using-sed.html...
1,623
Posted By kevintse
# this command changes all 0x0a to 0x0d0a in...
# this command changes all 0x0a to 0x0d0a in your_file
unix2dos your_file
1,623
Posted By kevintse
You probably need unix2dos and dos2unix. ...
You probably need unix2dos and dos2unix.
Windows uses 0x0d0a as newline, while Unix uses 0x0a.
5,035
Posted By kevintse
I think Using the i(insert) command would be more...
I think Using the i(insert) command would be more straightforward in this case.

---------- Post updated at 01:16 AM ---------- Previous update was at 01:15 AM ----------

sed -i '$ i\<user...
Showing results 1 to 25 of 248

 

Featured Tech Videos

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