Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

6 votes
1 answers
6255 views
How to add sensors and cooling devices to thermal-conf.xml
I have a Toshiba NB510-108 netbook with Xubuntu 14.10 installed. Under Windows 7 Starter, temperature sensors show values up to 45 degrees Celsius. Under Xubuntu, they show values up to 55 degrees. I would like to use thermald to keep the temperature at 38 degrees. My thermal-conf.xml file only cont...
I have a Toshiba NB510-108 netbook with Xubuntu 14.10 installed. Under Windows 7 Starter, temperature sensors show values up to 45 degrees Celsius. Under Xubuntu, they show values up to 55 degrees. I would like to use thermald to keep the temperature at 38 degrees. My thermal-conf.xml file only contains one sensor of type TSKN and two cooling devices of types rapl_controller and intel_powerclamp. sensors -u shows this user@user-TOSHIBA-NB510:~$ sensors -u acpitz-virtual-0 Adapter: Virtual device temp1: temp1_input: 42.000 temp1_crit: 110.000 coretemp-isa-0000 Adapter: ISA adapter Core 0: temp2_input: 43.000 temp2_crit: 100.000 temp2_crit_alarm: 0.000 Core 1: temp3_input: 43.000 temp3_crit: 100.000 temp3_crit_alarm: 0.000 Can anybody please tell me how to add the above sensors to thermal-conf.xml, and maybe also how to locate and add other cooling devices?
dfs (61 rep)
Dec 19, 2014, 11:30 AM • Last activity: Jul 13, 2025, 03:05 PM
1 votes
1 answers
4807 views
Posting to socket using curl
I'm struggling to get `curl` and `socat` to play nicely together. The situation is the following: 1. I post XML to log in to a system. 2. The returned message contains an authentication token. 3. I post subsequent requests with the token. Caveat: if the connection is broken, the token expires, so I...
I'm struggling to get curl and socat to play nicely together. The situation is the following: 1. I post XML to log in to a system. 2. The returned message contains an authentication token. 3. I post subsequent requests with the token. Caveat: if the connection is broken, the token expires, so I can't use plain curl. I need this to run in Linux. Since I need the connection to persist, I decided to use socat. If I run this to POST the XML: curl http://$target_ip -d @./xml/login.xml ... I get a proper answer from the system, but the connection is closed, so I can't reuse the token. However, if I try this (of course, after socat): curl --unix-socket /tmp/$target_ip.sock -d @./xml/login.xml Curl complains that I don't have the URL set.
Shiunbird (63 rep)
Jan 15, 2018, 03:34 PM • Last activity: Jun 5, 2025, 07:05 AM
0 votes
1 answers
61 views
Wget download wrong content
I'm trying to download a specific sitemap.xml (https://www.irna.ir/sitemap/all/sitemap.xml). The problem is that when you load the specific sitemap.xml for a few seconds one white page with a header on it (you are redirecting...) appears and then disappears. When I read the downloaded sitemap.xml it...
I'm trying to download a specific sitemap.xml (https://www.irna.ir/sitemap/all/sitemap.xml) . The problem is that when you load the specific sitemap.xml for a few seconds one white page with a header on it (you are redirecting...) appears and then disappears. When I read the downloaded sitemap.xml it was just a HTML file with the details of the redirect page, not the exact sitemap.xml that I wanted. **Part of the downloaded file(sitemap.xml)**:
var _this = this;
**Used command:** wget https://www.irna.ir/sitemap/all/sitemap.xml **Part of hat I want(sitemap.xml):**
https://www.irna.ir/sitemap/1403/12/22/sitemap.xml 


https://www.irna.ir/sitemap/1403/12/21/sitemap.xml 
I want to download the XML contents of the sitemap.xml, not the initial page (which two of them have the same URL)
Amirali (5 rep)
Mar 12, 2025, 03:17 PM • Last activity: Mar 12, 2025, 04:08 PM
2 votes
4 answers
274 views
Extract specific value from blocks of data
I have the blocks of data which are differentiated by the global Ids as below. I need to extract the last block of data with the highest id value, in the below example, `id="82"`. ---Remaining data--------- ---Remaining data--------- ---Remaining data--------- I can perform the below. However, it wi...
I have the blocks of data which are differentiated by the global Ids as below. I need to extract the last block of data with the highest id value, in the below example, id="82". ---Remaining data--------- ---Remaining data--------- ---Remaining data--------- I can perform the below. However, it will restrict the id value to be two digits only. How can I derive the last block of data without putting the digits restriction on id value. data1=grep "gc type="global"" abc.log| cut -c24-26|tail -n1 lastdata="gc type="global"=$data1" sed -n '/'"${lastdata}"'/,$p' abc.log>last_block_data.log
alex (121 rep)
Jul 31, 2015, 01:06 PM • Last activity: Mar 10, 2025, 09:33 PM
4 votes
4 answers
3342 views
Create CSV from an xml file
I'm trying to create a csv from an xml with just some information from the xml. This is my xml : ``` 2022-11-06T01:22:14+00:00 MacBook-Pro-de-Baptiste.local ARRI HDET job in-place A_0900C001_220927_102036_a1BZ0_hde.mxf 3f93f215ec277fc7 A_0900C002_220927_102120_a1BZ0_hde.mxf 6a3c2be7577f31bd A_0900C0...
I'm trying to create a csv from an xml with just some information from the xml. This is my xml :
2022-11-06T01:22:14+00:00
        MacBook-Pro-de-Baptiste.local
        ARRI HDET job
    
    
        in-place
    
    
        
            A_0900C001_220927_102036_a1BZ0_hde.mxf
            3f93f215ec277fc7
        
        
            A_0900C002_220927_102120_a1BZ0_hde.mxf
            6a3c2be7577f31bd
        
        
            A_0900C003_220927_102240_a1BZ0_hde.mxf
            6606cf4d3b1ebc17
        
        
            A_0900C004_220927_102334_a1BZ0_hde.mxf
            cd0a2dca6f8f6c21
        
        
            A_0900C005_220927_102506_a1BZ0_hde.mxf
            e617e05dae72e5a6
        
        
            A_0900C006_220927_102615_a1BZ0_hde.mxf
            d6e487264d1246b0
        
        
            A_0900C007_220927_102720_a1BZ0_hde.mxf
            80f5f5683e1f326d
And I want something like that : A_0900C001_220927_102036_a1BZ0_hde.mxf;3f93f215ec277fc7 A_0900C002_220927_102120_a1BZ0_hde.mxf;6a3c2be7577f31bd etc... I've tried
xmllint --xpath '/hashlist/hashes/hash/path/text()' file.xml
but the return is "XPath set is empty"
MrBotus (41 rep)
Nov 8, 2022, 12:54 PM • Last activity: Feb 15, 2025, 05:21 PM
-1 votes
3 answers
114 views
sed command gets me error Label too long: on solaris
Given database name `oltt206` or `DB01` i wish to extract its respective `username`, `password` and `connection string` from the xml below: wladmin@myremhost:/tmp$ cat /web/bea_apps/uat/Tomcat_Home_v9.0.56/TomcatNode01/conf/server.xml --> --> --> --> --> --> --> --> I tried the following command on...
Given database name oltt206 or DB01 i wish to extract its respective username, password and connection string from the xml below: wladmin@myremhost:/tmp$ cat /web/bea_apps/uat/Tomcat_Home_v9.0.56/TomcatNode01/conf/server.xml --> --> --> --> --> --> --> --> I tried the following command on solaris but it fails: Error Output: wladmin@remhost:$ sed -n '/
Ashar (527 rep)
Jan 28, 2024, 10:43 PM • Last activity: Jan 31, 2025, 06:40 AM
0 votes
4 answers
2017 views
how to remove New line character using Sed or perl
I have a huge file of XML data containing the lines like some of the data some of the data some of the data some of the data some of the data In between I am getting the newline character... $>uname -a SunOS ******* 5.11 SunOS_Development
I have a huge file of XML data containing the lines like some of the data some of the data some of the data some of the data some of the data In between I am getting the newline character... $>uname -a SunOS ******* 5.11 SunOS_Development
vinay desai (9 rep)
Nov 6, 2019, 10:48 AM • Last activity: Dec 18, 2024, 01:22 PM
-1 votes
2 answers
67 views
How to print the content inside the tag using grep command?
In linux, how can we use grep command to print the contents that comes inside this tag? XXXXXXXX I tried `grep -Po ' ' abc.log`, but it only prints ` `
In linux, how can we use grep command to print the contents that comes inside this tag? XXXXXXXX I tried grep -Po '' abc.log, but it only prints ``
Prateek (101 rep)
Nov 25, 2024, 01:33 PM • Last activity: Nov 25, 2024, 06:43 PM
1 votes
5 answers
8974 views
Replace an XML attribute's value with the value of a shell variable
I have the above sample data. In which file will have FOLDER NAME with some value. I have to replace it with some other value which is a variable I want to replace FOLDER NAME="ABC" with DEF sed -i "s/<FOLDER NAME=\"\*\"/<FOLDER NAME=\"$FLDR\"/g" Gather.XML Above sed commands doesn't through any err...
I have the above sample data. In which file will have FOLDER NAME with some value. I have to replace it with some other value which is a variable I want to replace FOLDER NAME="ABC" with DEF sed -i "s/
user_297020 (59 rep)
Jun 26, 2018, 07:22 AM • Last activity: Oct 24, 2024, 09:45 AM
1 votes
3 answers
304 views
Sed command not matching and replacing pattern on multi line xml
I have many XML files as below where i would like to replace a string with a new string. I cannot seem to get the sed command to work on the xml files. Forcepoint DLP Dashboard - LongTerm Activity for those with Long-Term Exceptions Timeframe -48h@h now Macros In Use: `ForcepointApprovedUSB` = Known...
I have many XML files as below where i would like to replace a string with a new string. I cannot seem to get the sed command to work on the xml files. Forcepoint DLP Dashboard - LongTerm Activity for those with Long-Term Exceptions Timeframe -48h@h now

Macros In Use:

ForcepointApprovedUSB = Known Approved USB Devices

ForcepointKnownCDDVD = Known CD/DVD Drives

ForcepointKnownMultiFunction = Known Multi-Function Devices

Exception Info index=restricted_security sourcetype=forcepoint | rex field=_raw "(.*act=(?.*?)\s.*)" | rex field=_raw "(.*duser=(?.*?)(:\s\d|;|\sfname=).*)" | rex field=_raw "(.*duser=.*?;\s(?.*?)\sfname=)" | rex field=_raw "(.*fname=(?.*?)\smsg=.*)" | rex field=_raw "(.*fname=.:\\\(?.*)(?:\s-\s.*)\smsg=.*)" | rex field=_raw "(.*suser=(?.*)\scat=.*)" | rex field=_raw "(.*loginName=.*\\\\(?.*)\ssourceIp=.*)" | rex field=_raw "(.*sourceIp=(?.*)\sseverityType=.*)" | rex field=_raw "(.*sourceHost=(?.*)\sproductVersion=.*)" | rex field=_raw "(.*sourceServiceName=(?.*)\sanalyzedBy=.*)" | eval Username=lower(Username) | eval Action=if(isnull(Action),"-",Action) | eval Serial=if(isnull(Serial),"-",Serial) | eval EnumDeviceType=case( (ForcepointApprovedUSB),"ApprovedUSB", (ForcepointKnownCDDVD),"CDDVD", (ForcepointKnownMultiFunction),"MultiFunction", AlertType="Endpoint Applications" AND Device="Bluetooth","Bluetooth", AlertType="Endpoint Removable Media" AND Device="Windows Portable Device (WPD)","WPD", AlertType="Endpoint Removable Media" AND Device!="Windows Portable Device (WPD)" AND NOT (ForcepointApprovedUSB) AND NOT (ForcepointKnownCDDVD) AND NOT (ForcepointKnownMultiFunction),"UnApprovedUSB") | join type=inner Username [ search index=restricted_security sourcetype=dlp_lt | rename UserID as Username | eval Check = "Yes" | fields Username,Check,Justification,Type,ExpireDate ] | where isnotnull(EnumDeviceType) AND Check="Yes" | eval Time=strftime(_time, "%B %d, %Y %H:%M %Z") | dedup Username | table Time Username Name Justification Type ExpireDate | sort Name $TimeFrame.earliest$ $TimeFrame.latest$ none progressbar Transfers By Those With Long-Term Exceptions index=restricted_security sourcetype=forcepoint | rex field=_raw "(.*act=(?.*?)\s.*)" | rex field=_raw "(.*duser=(?.*?)(:\s\d|;|\sfname=).*)" | rex field=_raw "(.*duser=.*?;\s(?.*?)\sfname=)" | rex field=_raw "(.*fname=(?.*?)\smsg=.*)" | rex field=_raw "(.*fname=.:\\\(?.*)(?:\s-\s.*)\smsg=.*)" | rex field=_raw "(.*suser=(?.*)\scat=.*)" | rex field=_raw "(.*loginName=.*\\\\(?.*)\ssourceIp=.*)" | rex field=_raw "(.*sourceIp=(?.*)\sseverityType=.*)" | rex field=_raw "(.*sourceHost=(?.*)\sproductVersion=.*)" | rex field=_raw "(.*sourceServiceName=(?.*)\sanalyzedBy=.*)" | eval Username=lower(Username) | eval Action=if(isnull(Action),"-",Action) | eval Serial=if(isnull(Serial),"-",Serial) | eval EnumDeviceType=case( (ForcepointApprovedUSB),"ApprovedUSB", (ForcepointKnownCDDVD),"CDDVD", (ForcepointKnownMultiFunction),"MultiFunction", AlertType="Endpoint Applications" AND Device="Bluetooth","Bluetooth", AlertType="Endpoint Removable Media" AND Device="Windows Portable Device (WPD)","WPD", AlertType="Endpoint Removable Media" AND Device!="Windows Portable Device (WPD)" AND NOT (ForcepointApprovedUSB) AND NOT (ForcepointKnownCDDVD) AND NOT (ForcepointKnownMultiFunction),"UnApprovedUSB") | join type=inner Username [ search index=restricted_emn_security sourcetype=dlp_lt | rename UserID as Username | eval Check = "Yes" | dedup Username | fields Username, Check ] | where isnotnull(EnumDeviceType) AND Check="Yes" | eval Time=strftime(_time, "%B %d, %Y %H:%M %Z") | table Time Username Name Action Source Filename Device Serial EnumDeviceType | sort -Time $TimeFrame.earliest$ $TimeFrame.latest$ 30 none The pattern i would like to replace is index=restricted_security sourcetype=forcepoint with index=newname sourcetype=forcepoint So any pattern where index=restricted_security sourcetype=forcepoint should be replaced with the new value. The XML files have many combinations like index=restricted_security sourcetype=someother value, index=someindex sourcetype=forcepoint etc but they don't need to be replaced. I have tried many patterns like below with many combinations of sed but it does not seem to work sed 's/index=restricted_security\s\nsourcetype=forcepoint/index=restricted_security sourcetype=forcepoint/g' Can someone please point out how to get this to replace?
ranjit abraham (145 rep)
Oct 10, 2024, 02:45 PM • Last activity: Oct 11, 2024, 02:18 PM
3 votes
3 answers
186 views
SED command to delete a forward slash "/" between 2 tags
I am using Linux, and I want to use `sed` to delete a forward slash (`/`) between 2 tags. From this: `input.xml`... ```xml /text /text2 /text ``` ...to this: `output.xml`: ```xml text text2 text ``` Tested a lot of codes without success, for example: ```bash sed s'/ /s|^\.{1,2}/||' fileout ``` can y...
I am using Linux, and I want to use sed to delete a forward slash (/) between 2 tags. From this: input.xml...
/text
/text2
/text
...to this: output.xml:
text
text2
text
Tested a lot of codes without success, for example:
sed s'//s|^\.{1,2}/||' fileout
can you help?
Allan Tori (47 rep)
Feb 27, 2024, 08:38 AM • Last activity: Sep 25, 2024, 12:13 PM
2 votes
3 answers
7795 views
Update of XML value with xmlstarlet
I have file `config.xml`: ```xml App title Dummy dummy text. ``` I'd like to change value of ` ` element. I've tried following: ```bash xmlstarlet edit -L -u "/_:widget/name" -v "NEW_NAME" config.xml ``` and ```bash xmlstarlet edit -L -u "//name" -v "NEW_NAME" config.xml ``` But it hasn't changed th...
I have file config.xml:
App title
    Dummy dummy text.
I'd like to change value of `` element. I've tried following:
xmlstarlet edit -L -u "/_:widget/name" -v "NEW_NAME" config.xml
and
xmlstarlet edit -L -u "//name" -v "NEW_NAME" config.xml
But it hasn't changed the App title value.
Ladislav M (123 rep)
Nov 23, 2014, 08:45 PM • Last activity: Sep 25, 2024, 05:49 AM
5 votes
3 answers
6114 views
sed remove lines in range
I have an xml file. I am trying to remove only the blank lines from a range of lines. In this example I want to check lines 55-57 and remove any blank lines. This needs to be done in a shell script over multiple files that are all xml. This is a RHEL 7 system. I tried using `sed`, but wasn't able to...
I have an xml file. I am trying to remove only the blank lines from a range of lines. In this example I want to check lines 55-57 and remove any blank lines. This needs to be done in a shell script over multiple files that are all xml. This is a RHEL 7 system. I tried using sed, but wasn't able to strip the empty lines out. I have written statements that get the appropriate line numbers, they are stored as vars in the shell script (start_line, finish_line) Example File: 1. 2. 3. . . . 55. 56. 57. 58. What can I do to remove the blank lines only from range 55-57?
Enter Strandman (149 rep)
Jun 17, 2020, 02:46 PM • Last activity: Aug 28, 2024, 09:05 PM
0 votes
1 answers
902 views
Insert a tag with a unique identifier into a XML
I'm able to add a new node with a custom fixed value to my XML file in this way, with [xmlstarlet][1]: xmlstarlet ed --subnode "/legge190/data/lotto" --type elem -n newsubnode \ -v "myvalue" But how to add a unique identifier? If I try to add a unique identifier using `generate-id(.)` xmlstarlet ed...
I'm able to add a new node with a custom fixed value to my XML file in this way, with xmlstarlet : xmlstarlet ed --subnode "/legge190/data/lotto" --type elem -n newsubnode \ -v "myvalue" But how to add a unique identifier? If I try to add a unique identifier using generate-id(.) xmlstarlet ed --subnode "/legge190/data/lotto" --type elem -n newsubnode \ -v "generate-id(.)" I do not have an id value, but the generate-id(.) string. Thank you
aborruso (2995 rep)
Sep 24, 2017, 03:42 PM • Last activity: Jul 23, 2024, 10:45 AM
1 votes
2 answers
72 views
Use sed to insert a character in an xml file
I have an xml file with content following this format: 000000 FFFFFF The information within the tags are hex colors (many different colors), but they need to begin with a pound sign (#) to work in a particular application, ie: #000000 #FFFFFF How can I use sed to append the pound symbol in this file...
I have an xml file with content following this format: 000000 FFFFFF The information within the tags are hex colors (many different colors), but they need to begin with a pound sign (#) to work in a particular application, ie: #000000 #FFFFFF How can I use sed to append the pound symbol in this file? Using sed 4.8 BTW, thanks!
jon danniken (33 rep)
Jul 8, 2024, 06:13 PM • Last activity: Jul 9, 2024, 02:37 PM
3 votes
5 answers
49616 views
create XML file using bash script
I want create simple xml file using bash script ( not with dom ) but when I set value in the line then **echo** print the $lorem word and not the val **lorem=LOL** echo ' $lorem ' >> $MY_XML I also try this echo ' \$lorem ' >> $MY_XML echo ' "$lorem" ' >> $MY_XML echo ' \"$lorem\" ' >> $MY_XML but a...
I want create simple xml file using bash script ( not with dom ) but when I set value in the line then **echo** print the $lorem word and not the val **lorem=LOL** echo '$lorem' >> $MY_XML I also try this echo '\$lorem' >> $MY_XML echo '"$lorem"' >> $MY_XML echo '\"$lorem\"' >> $MY_XML but all these print the exactly the line and not the val please advice how to print the val $lorem ? as the following example LOL
maihabunash (7231 rep)
Feb 9, 2015, 08:28 AM • Last activity: Jun 5, 2024, 10:02 AM
-2 votes
1 answers
73 views
Parse txt file on basis of occurrence of a tag in Linux
I am trying to parse a txt file containing xml "messages"in linux, something like this ``` xyz xyz xyz xyz and so on ``` The code will read file, extract each section from ``` ``` till ``` ``` and put each section into a separate file. My code for this is as below ``` input_file="input_file.txt" # E...
I am trying to parse a txt file containing xml "messages"in linux, something like this
xyz     xyz     xyz     xyz   and so on
The code will read file, extract each section from
till
and put each section into a separate file. My code for this is as below
input_file="input_file.txt"

# Extracting Document parts
sed -n '//p' "$input_file" > temp_output.txt

# Splitting into Different Files
csplit -f output -b %d.txt -z temp_output.txt '//' '{*}'

# Cleaning up temporary files
rm temp_output.txt
However, this code is extracting several xml messages into one file, particularly the ones with no line break. Could someone suggest what can be rectified in the above code?
python6 (1 rep)
May 15, 2024, 01:29 PM • Last activity: May 15, 2024, 02:09 PM
1 votes
3 answers
64 views
using grep (or something similar) to find when rows are missing
I'm trying to find when certain rows are missing in a file. See below. In each record, there is an ItemNumber, MessageNumber, NewItemNumber, and ConfirmedQty field. Is there a way to find ItemNumber where NewItemNumber is missing, as in the last record here? 30353 000 30353 1 30354 000 30354 1 30391...
I'm trying to find when certain rows are missing in a file. See below. In each record, there is an ItemNumber, MessageNumber, NewItemNumber, and ConfirmedQty field. Is there a way to find ItemNumber where NewItemNumber is missing, as in the last record here? 30353 000 30353 1 30354 000 30354 1 30391 000 30391 1 71067 000 71067 1 ** 29424 035 0 **
Dan (11 rep)
May 7, 2024, 02:52 PM • Last activity: May 8, 2024, 01:04 PM
-1 votes
3 answers
138 views
sed inline not working to modify XML-style input
the problem is that I cannot put the complete command on a line with SED, I had already done it but with those file it does not work: my exemple : Documents/time/text1 //2X slash + 2 words to remove !! Commun/text2 //1X slash to remove + 1 words to remove Current/text3 //1X slash to remove + 1 words...
the problem is that I cannot put the complete command on a line with SED, I had already done it but with those file it does not work: my exemple : Documents/time/text1 //2X slash + 2 words to remove !! Commun/text2 //1X slash to remove + 1 words to remove Current/text3 //1X slash to remove + 1 words to remove Why does this code not work in line ?
sed 's/Documents//g' | sed 's/time//g' | sed 's/Commun//g' | sed 's/Current//g' | sed 's/Current//g' | sed '//s|/||' | sed '//s|/||' tracklist.txt > newtracklist.txt
Allan Tori (47 rep)
Feb 27, 2024, 08:00 PM • Last activity: Mar 24, 2024, 10:06 PM
0 votes
2 answers
168 views
Renaming xml file based on tag
I have a number of xml files. I need to rename each based on the specific tag (say `tag1="alpha"`) inside the xml. I have figured out how to rename the file based on _single_ occurance of the specific tag. ``` find . -maxdepth 1 -name '*.xml' -exec /rename.sh {} \; ``` ``` #!/bin/bash tag1=$(sed 's/...
I have a number of xml files. I need to rename each based on the specific tag (say tag1="alpha") inside the xml. I have figured out how to rename the file based on _single_ occurance of the specific tag.
find . -maxdepth 1 -name '*.xml' -exec /rename.sh {} \;
#!/bin/bash

tag1=$(sed 's/.*tag1="\([^"]*\).*/\1/; q' "$1")
mv -v "$1" "$tag1.xml"
The problem: some files have multiple tag1 tags, e.g. tag1="alpha" tag1="beta" tag1="omega". With these files I need to also create a copies of the same file, but with the other names, beta.xml, omega.xml. I tried to cat with positional parameters but that didn't work (I am a beginner). **file structure example:**
cudg.el | ˈ;ke;je;lˈ;ke;dʒe;l | noun a short, thick stick used as a weapon. verb (, ; British ) [with object] beat with a cudgel : they would lie in wait and cudgel her to death . PHRASES (also ) British think hard about a problem : she cudgeled her brains, trying to decide what had caused such an about-face . start to defend or support someone or something strongly : there was no one else to take up the cudgels on their behalf . ORIGIN Old English cycgel, of unknown origin.
Simon Ante (1 rep)
Jul 20, 2022, 07:23 PM • Last activity: Mar 10, 2024, 05:07 PM
Showing page 1 of 20 total questions