sorting html in shell script - html

I have a file with an html code inside it
Is there a way to sort the content by names? such that the file is now sorted like:
Thanks :)

Yes, simply run this command :
sort -t '>' -k 3 filename
I think you have an error in your wanted output : Chan should be before deLtorro.
By the way, can you tell us what are you trying to achieve finally ? Maybe that's not the better way.

Related

How to sort a CSV file using Windows command line?

I have a file like this:
9007,5001,800085,,100,40.00,,,,,20170923,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,9995,,100,40.00,,,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,35787654,,370,2.00,,,,,20170923,,,8157,60405,,,,,,,5001,,,,,51815720718
2001,5001,557,,370,4.25,,,,,20170930,,,8157,60405,,,,,,,5001,,,,,51815720718
9007,5001,657,,704,3.75,,4,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718
And I have to sort the file like this:
2001,5001,557,,370,4.25,,,,,20170930,,,8157,60405,,,,,,,5001,,,,,51815720718
9007,5001,657,,704,3.75,,4,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,800085,,100,40.00,,,,,20170923,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,9995,,100,40.00,,,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,35787654,,370,2.00,,,,,20170923,,,8157,60405,,,,,,,5001,,,,,51815720718
I had used sort FileName command but that is of no use because I am getting result like:
2001,5001,557,,370,4.25,,,,,20170930,,,8157,60405,,,,,,,5001,,,,,51815720718
9007,5001,35787654,,370,2.00,,,,,20170923,,,8157,60405,,,,,,,5001,,,,,51815720718
9007,5001,657,,704,3.75,,4,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,800085,,100,40.00,,,,,20170923,,,8157,60400,,,,,,,5001,,,,,51815720718
9007,5001,9995,,100,40.00,,,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718
Can anyone help me on this task please?
Javascript is used to manipulate DOM Elements. CMD and Javascript are two different dimensions.

Converting Shell Output to json

I want to convert the output of octave execution in shell to json format.
For example if I execute
$ octave --silent --eval 'a=[1,3],b=2'
I get
a =
1 3
b = 2
I want the output to be formatted to a json string as in
"{'a':[1,3], 'b':2}"
How do I achieve this, It would be great if it is in node/js, but anthing is fine. I am looking for any existing solutions to rather than writing my own logic for parsing it. Need suggestion.
I doubt if any such package exists. Its easy to write your own rather thank waiting to find one.

When match a char in a csv field, replace it by the column title concatenate with another filed on the same rank

I have a csv that contain domain list and a tick on each extension column i possess :
num;domaine;fr;com;xxx;net;eu;org;info;asia;com.tw;hk;mobi;net.cn;org.cw;tw
1;mydomain1;x;;;;;;;;;;;;;
2;mydomain2;x;x;x;x;;;;;;;;;;
3;mydomain3;x;x;x;x;x;x;;;;;;;;*
I'd like to create a text file from this csv that contain all the domain.extension :
mydomain1.fr
mydomain2.fr
mydomain2.com
mydomain2.xxx
mydomain2.net
mydomain3.fr
mydomain3.com
mydomain3.xxx
etc.
i made some dirty thing with sed and case but i'm sure a better brain could give me some tips to solve it.
Thanks in advance
kent$ awk -F';' 'NR==1{for(i=3;i<=NF;i++)d[i]=$i;next}
{for(i=3;i<=NF;i++)if($i=="x")print $2"."d[i]}' file
mydomain1.fr
mydomain2.fr
mydomain2.com
mydomain2.xxx
mydomain2.net
mydomain3.fr
mydomain3.com
mydomain3.xxx
mydomain3.net
mydomain3.eu
mydomain3.org
shorter version:
awk -F';' '{for(i=3;i<=NF;i++)if(NR==1)d[i]=$i;else if($i=="x")print $2"."d[i]}' file

Printing JSON-formatted data in Tcl

Hi I need to print the following as it is in tcl.
{'root':[{'name':'Test', 'val':'1'},{'name':'Test2', 'val':'3'}]}
when i do the following I get an error
puts "{'root':[{'name':'$name', 'val':'$val'},{'name':'$name', 'val':'$val'}]}"
Is there a way i can print those in tcl?
ok I tried this now:
puts "{'root':\[{'name':'$name', 'val':'$id'}"
but that doesnt work either
Remember that the '[' means that you want to execute something, so you need to escape it.
puts "{'root':\[{'name':'$name', 'val':'$val'},{'name':'$name','val':'$val'}\]}"
With those changes, should work.
Also, you can find more examples of how to manage JSON in tcl here: http://wiki.tcl.tk/13419
It's just
puts {{'root':[{'name':'Test', 'val':'1'},{'name':'Test2', 'val':'3'}]}}
That is, put the whole string between { and } to make it "literal".
More info is in the tutorial.

Replacing output text of a command with a string in a Shell Script

Hello and thank you for any help you can provide
I have my Apache2 web server set up so that when I go to a specific link, it will run and display the output of a shell script stored on my server. I need to output the results of an SVN command (svn log). If I simply put the command 'svn log -q' (-q for quiet), I get the output of:
(of course not blurred), and with exactly 72 dashes in between each line. I need to be able to take these dashes, and turn them into an html line break, like so:
Basically I need the shell script to take the output of the 'svn log -q' command, search and replace every chunk of 72 dashes with an html line break, and then echo the output.
Is this at all possible?
I'm somewhat a noob at shell scripting, so please excuse any mess-ups.
Thank you so much for your help.
svn log -q | sed -e 's,-{72},<br/>,'
If you want to write it in the script this might help:
${string//substring/replacement}
Replace all matches of $substring with $replacement.
stringZ=abcABC123ABCabc
echo ${stringZ/abc/xyz} # xyzABC123ABCabc
# Replaces first match of 'abc' with 'xyz'.
echo ${stringZ//abc/xyz} # xyzABC123ABCxyz
# Replaces all matches of 'abc' with # 'xyz'.