是否可以使用Bash连接两个节点变量?
我正在尝试联系这4个变量
具有类似“ 5216997,是的,标记,请求”之类的内容
IncidentId="$(echo "cat /incidents/incident/id/text()" | xmllint --nocdata --shell ~/Desktop/Chicago.csv | sed '1d;$d')"
is_customer_satisfied="$(echo "cat /incidents/incident/is_customer_satisfied/text()" | xmllint --nocdata --shell ~/Desktop/Chicago.csv | sed '1d;$d')"
requester="$(echo "cat /incidents/incident/requester/name/text()" | xmllint --nocdata --shell ~/Desktop/Chicago.csv | sed '1d;$d')"
category="$(echo "cat /incidents/incident/category/name/text()" | xmllint --nocdata --shell ~/Desktop/Chicago.csv | sed '1d;$d')"
但是我确实有这个:
5216172 ------- 5215298 | -------是-------是| -------马克-------吕克| -------请求-------请求
或者这是一种更好的方法,我正在寻找什么?
csv文件内容xml值:
> <?xml version="1.0" encoding="UTF-8"?>
<incidents>
<incident>
<id>5237425</id>
<number>5101</number>
<name>Google Mail Password Reset</name>
<description></description>
<description_no_html></description_no_html>
<state>Closed</state>
<priority>Low</priority>
<category>
<id>371032</id>
<name>Software</name>
<default_tags>Software</default_tags>
<children>
<child>
<id>505786</id>
<name>Accounts</name>
<default_tags>Google, google, gmail, AppleId, appleid, Uniflow, </default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
<child>
<id>371040</id>
<name>Email/Outlook</name>
<default_tags>Mail/Outlook, Email, Outlook</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
<child>
<id>423866</id>
<name>iOS</name>
<default_tags>iOS</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
<child>
<id>371044</id>
<name>macOS</name>
<default_tags>macOS</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
<child>
<id>371043</id>
<name>MS office (Word, Excel,...)</name>
<default_tags>MS office, Word, Excel, Access</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
<child>
<id>371047</id>
<name>Other Software</name>
<default_tags>Other Software</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
<child>
<id>371046</id>
<name>Windows</name>
<default_tags>Windows</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</child>
</children>
<parent_id nil="true"/>
<default_assignee_id>-1</default_assignee_id>
</category>
<subcategory>
<id>371040</id>
<name>Email/Outlook</name>
<default_tags>Mail/Outlook, Email, Outlook</default_tags>
<children nil="true"/>
<parent_id>371032</parent_id>
<default_assignee_id>-1</default_assignee_id>
</subcategory>
<assignee>
<group_id>1518184</group_id>
<is_user>true</is_user>
<id>1323154</id>
<name>Mark</name>
<disabled>false</disabled>
<title>IT Support Administrator</title>
<created_at>2017-01-30T16:06:46+01:00</created_at>
<last_login>2018-03-01T09:23:45+01:00</last_login>
<phone> 22</phone>
<mobile_phone> 36</mobile_phone>
<department>
<id>20501</id>
<name>IT</name>
<description>IT Team</description>
<default_assignee_id>-1</default_assignee_id>
</department>
<role>
<id>233084</id>
<name>IT support</name>
<description></description>
<portal>false</portal>
<show_my_tasks>false</show_my_tasks>
</role>
<salt>0ec80dd90d499c4e80307fd8128f6e267717ae9b</salt>
<group_ids>
<group_id>1518184</group_id>
<group_id>1499663</group_id>
<group_id>1539645</group_id>
</group_ids>
<custom_fields_values/>
<avatar>
<type>initials</type>
<color>#0bc46f</color>
<initials>ML</initials>
</avatar>
<mfa_enabled>false</mfa_enabled>
<reports_to>
<group_id>1500982</group_id>
<is_user>true</is_user>
<id>1308247</id>
<name>Stéphane</name>
<disabled>false</disabled>
<title>IT Support</title>
<email>user@test.com</email>
<created_at>2016-10-21T09:55:42+02:00</created_at>
<last_login>2018-05-28T08:04:33+02:00</last_login>
<phone> 47 95</phone>
<mobile_phone>+41 14 24</mobile_phone>
<department>
<id>20501</id>
<name>IT</name>
<description>IT Team</description>
<default_assignee_id>-1</default_assignee_id>
</department>
<role>
<id>225674</id>
<name>Administrator</name>
<description>This is the all powerful administrator user!</description>
<portal>false</portal>
<show_my_tasks>false</show_my_tasks>
</role>
<salt>bde321c1b90d43d1af1b12140ad2528cadc69672</salt>
<group_ids>
<group_id>1500982</group_id>
</group_ids>
<custom_fields_values/>
<avatar>
<type>image</type>
<image_class>avatar_image</image_class>
<sso_image_class></sso_image_class>
<avatar_url></avatar_url>
</avatar>
<mfa_enabled>false</mfa_enabled>
<site>
<id>23927</id>
<name>IT</name>
<location>London</location>
<description>London</description>
<time_zone>Bern</time_zone>
<language>-1</language>
<business_record>
<id>28860</id>
<name>Default Business Hours</name>
<description>This is your initial business hours record</description>
</business_record>
</site>
</reports_to>
<site>
<id>23926</id>
<name>London</name>
<location>london</location>
<description>London</description>
<time_zone>Bern</time_zone>
<language>-1</language>
<business_record>
<id>28860</id>
<name>Default Business Hours</name>
<description>This is your initial business hours record</description>
</business_record>
</site>
</assignee>
<requester>
<id>1157306</id>
<account_id>34933</account_id>
<user_id>1393446</user_id>
<email>user@london.com</email>
<name>Student - Leysin</name>
<disabled>false</disabled>
<has_gravatar>false</has_gravatar>
<customer_satisfaction_survey_time>2018-06-08T15:01:57+02:00</customer_satisfaction_survey_time>
<avatar>
<type>initials</type>
<color>#bb5bac</color>
<initials>SL</initials>
</avatar>
</requester>
<created_at>2018-06-26T11:12:32+02:00</created_at>
<updated_at>2018-06-26T11:12:32+02:00</updated_at>
<due_at nil="true"/>
<sla_violations/>
<number_of_comments>0</number_of_comments>
<user_saw_all_comments>true</user_saw_all_comments>
<is_service_request>false</is_service_request>
<created_by>
<id>1089626</id>
<account_id>34933</account_id>
<user_id>1323154</user_id>
<email>user@test.com</email>
<name>Mark</name>
<disabled>false</disabled>
<has_gravatar>false</has_gravatar>
<customer_satisfaction_survey_time>2018-06-27T11:10:20+02:00</customer_satisfaction_survey_time>
<avatar>
<type>initials</type>
<color>#0bc46f</color>
<initials>ML</initials>
</avatar>
</created_by>
<custom nil="true"/>
<href>https://website.com/incidents/5237425-reset.xml</href>
<site>
<id>23926</id>
<name>London</name>
<location>London</location>
<description>London</description>
<time_zone>Bern</time_zone>
<language>-1</language>
<business_record>
<id>28860</id>
<name>Default Business Hours</name>
<description>This is your initial business hours record</description>
</business_record>
</site>
<department>
<id>26020</id>
<name>Students</name>
<description>Students</description>
<default_assignee_id>-1</default_assignee_id>
</department>
<cc/>
<custom_fields_values/>
<comments/>
<attachments/>
<statistics>
<statistic>
<statistic_type>State Changed</statistic_type>
<time>00:01</time>
<time_elapsed>00:01</time_elapsed>
<business_time_elapsed>00:01</business_time_elapsed>
<value>2018-06-26 09:12:32 UTC</value>
</statistic>
<statistic>
<statistic_type>first_touch_resolution</statistic_type>
<time nil="true"/>
<time_elapsed nil="true"/>
<business_time_elapsed nil="true"/>
<value>t</value>
</statistic>
</statistics>
<tags>
<tag>
<id>299260</id>
<name>software</name>
<taggings_count>9349</taggings_count>
</tag>
</incident>
</incidents>
答案 0 :(得分:0)
我使用xmlstarlet,效果更好