小编LOl*_*ffe的帖子

如何在运行shell脚本后让Mac".command"文件自动退出?

在我的shell脚本中,我的最后一行是:

...
echo "$l" done
done

exit
Run Code Online (Sandbox Code Playgroud)

我将终端首选项设置为"当shell退出时:关闭窗口".在所有其他情况下,当我在"终端"中键入"exit"或"logout"时,窗口关闭,但对于此".command"文件(我可以双击我的shell脚本文件,脚本运行),关闭窗口,而文件的代码显示"退出",屏幕上显示的是:

...
$l done
logout

[Process completed]
Run Code Online (Sandbox Code Playgroud)

......窗户保持打开状态.有谁知道如何运行shell脚本,然后在完成时自动退出终端窗口?

谢谢!

macos shell scripting command

21
推荐指数
3
解决办法
2万
查看次数

如何将bash shell脚本转换为.bat文件?

我的Mac上有一个bash shell脚本,我需要转换为PC上的用户的.bat文件(至少,这就是我所说的).我想知道最好的方法,或者如果有人知道任何好的参考.我似乎没有向谷歌提出正确的问题,指出我正确的方向.

具体来说,我将如何做...

cd ~/Documents/DropFolder
Run Code Online (Sandbox Code Playgroud)

(...其中〜/等于用户主目录的根目录,无论用户名称如何)?

或者,在处理变量和"做"语句时......

for i in *.xml
do
  java -Xss650K -Xms128m -Xmx2048m -jar /Applications...
done
Run Code Online (Sandbox Code Playgroud)

最后,识别和使用基地名称......

  cp -p `basename $i .xml`.xml ~/Documents/ReadyForServer/`basename $i .xml`/
Run Code Online (Sandbox Code Playgroud)

感谢您提供任何指导或其他解决方案的建议.LO

bash shell scripting batch-file

15
推荐指数
2
解决办法
5万
查看次数

如何使用XSL检查外部文件是否存在?

我已经找到了很多引用Java和C的例子,但是我如何或者我可以检查是否存在使用XSL的外部文件.

首先,我意识到这只是一个片段,但它是一个巨大的样式表的一部分,所以我希望它足以显示我的问题.

    <!-- Use this template for Received SMSs -->
<xsl:template name="ReceivedSMS">
    <!-- Set/Declare "SMSname" variable (local, evaluates per instance) -->
    <xsl:variable name="SMSname">
        <xsl:value-of select=" following-sibling::Name"/>
    </xsl:variable>
    <fo:table font-family="Arial Unicode MS" font-size="8pt" text-align="start">
        <fo:table-column column-width=".75in"/>
        <fo:table-column column-width="6.75in"/>
        <fo:table-body>
            <fo:table-row>
                <!-- Cell contains "speakers" icon -->
                <fo:table-cell display-align="after">
                    <fo:block text-align="start">
                        <fo:external-graphic src="../images/{$SMSname}.jpg" content-height="0.6in"/>
Run Code Online (Sandbox Code Playgroud)

我想做的是,在一条"如果"的声明中,这{$SMSname}.jpg条线路就是这样.那是:

                     <fo:block text-align="start">
                        <xsl:if test="exists( the external file {$SMSname}.jpg)">
                            <fo:external-graphic src="../images/{$SMSname}.jpg" content-height="0.6in"/>                            
                        </xsl:if>
                        <xsl:if test="not(exists( the external file {$SMSname}.jpg))">
                            <fo:external-graphic src="../images/unknown.jpg" content-height="0.6in"/>                            
                        </xsl:if>
                    </fo:block>                       
Run Code Online (Sandbox Code Playgroud)

由于"分组"等,我正在使用XSLT 2.0.我希望这是可以做到的.我希望它更简单. …

xslt document xsl-fo external exists

14
推荐指数
2
解决办法
2万
查看次数

如何在XSL中防止重复?

如何防止重复条目进入列表,然后理想情况下,对该列表进行排序?我正在做的是,当缺少一个级别的信息时,从下面的级别获取信息,在上面的级别中构建缺失列表.目前,我有类似于这样的XML:

<c03 id="ref6488" level="file">
    <did>
        <unittitle>Clinic Building</unittitle>
        <unitdate era="ce" calendar="gregorian">1947</unitdate>
    </did>
    <c04 id="ref34582" level="file">
        <did>
            <container label="Box" type="Box">156</container>
            <container label="Folder" type="Folder">3</container>
        </did>
    </c04>
    <c04 id="ref6540" level="file">
        <did>
            <container label="Box" type="Box">156</container>
            <unittitle>Contact prints</unittitle>
        </did>
    </c04>
    <c04 id="ref6606" level="file">
        <did>
            <container label="Box" type="Box">154</container>
            <unittitle>Negatives</unittitle>
        </did>
    </c04>
</c03>
Run Code Online (Sandbox Code Playgroud)

然后我应用以下XSL:

<xsl:template match="c03/did">
    <xsl:choose>
        <xsl:when test="not(container)">
            <did>
                <!-- If no c03 container item is found, look in the c04 level for one -->
                <xsl:if test="../c04/did/container">

                    <!-- If a c04 container item is found, use the …
Run Code Online (Sandbox Code Playgroud)

xslt duplicates

8
推荐指数
1
解决办法
5787
查看次数

使用shell脚本时,如何复制名称包含空格和UNICODE的文件?

我有一个文件列表,我试图在bash shell脚本中复制和移动(使用cp和mv).我遇到的问题是,我无法获得任何命令来识别大量文件,似乎因为文件名包含空格和/或unicode字符.我找不到任何开关来解码/重新编码这些字符.相反,例如,如果我复制"file name.xml",我会得到"*.xml"和脚本错误,表明找不到我的结果文件.有没有人知道将处理这些文件的设置或命令?

编辑(添加当前代码):当我运行时:

MacBookPro:桌面$ ./script.sh

#!/bin/sh
dateVar=`date +%Y-%m-%d`
mkdir /Volumes/Documents/SMSarchive/$dateVar
cd /Volumes/Documents/SMSarchive/SMSdrop
for i in *.xml
do
cp $i /Volumes/Documents/SMSarchive/$dateVar/$dateVar-$i
done
Run Code Online (Sandbox Code Playgroud)

我收到消息:

用法:cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file ... target_directory

......当它命中"cp"命令时.脚本实际上还有更多,它可以进一步处理复制的文件.使用"常规"文件名,例如'file.xml',一切正常.它只是带有空格或Unicode字符的文件,我遇到问题.

unicode bash shell scripting file

5
推荐指数
1
解决办法
1万
查看次数

使用 (imagemagick) `mogrify` 将 webp 文件转换为动画 gif 时如何避免丢失?

使用 mogrify -format gif *.webp 我在另一个论坛 https://superuser.com/questions/1506337/batch-convert-webp-files-to-gif-files-offline/1506428中找到的代码将 webp 文件转换为动画 gif.. 。

我想知道是否有其他人在使用这种方法时经历过黑色和/或白色“丢失”的斑块?对于许多文件,它可以正常工作,但对于其他文件,例如附件,我必须使用在线转换器来避免此问题。是否有我可以应用的其他过滤器或用于此类转换的其他 CLI 方法?

辍学结果

imagemagick command-line-interface animated-gif mogrify webp

5
推荐指数
1
解决办法
4097
查看次数

如何从XSL中的字符中去除重音?

我一直在寻找,但是对于字符来说,找不到相当于"normalize-space"的XSL函数.也就是说,我的内容重音了UNICODE字符,这很棒,但是根据这些内容,我正在创建一个文件名,我不想要那些重音符号.

那么,有什么东西我可以忽略,或者没有正确搜索,以便轻松处理角色?

在XML数据中:

<filename>gri_gonéwiththèw00mitc</filename>
Run Code Online (Sandbox Code Playgroud)

在XSLT样式表中:

<xsl:variable name="file">
    <xsl:value-of select="filename"/>
</xsl:variable>

<xsl:value-of select="$file"/>
Run Code Online (Sandbox Code Playgroud)

结果"gri_gonéwiththèw00mitc"

哪里

<xsl:value-of select='replace( normalize-unicode( "$file", "NFKD" ), "[^\\p{ASCII}]", "" )'/>
Run Code Online (Sandbox Code Playgroud)

没有结果.

我的目标是gri_gonewiththew00mitc(没有口音)

我使用的语法错了吗?

xml xslt unicode character-encoding

4
推荐指数
1
解决办法
1万
查看次数

如何使用XSLT将HTML百分比编码转换为Unicode?

关于这一点,网上有大量的条目和答案,但它们都与我需要的方向相反.从我的iTunes XML中,我有多种语言的数百%编码条目,我正在尝试使用XSLT样式表将其转换为Unicode文本.除了追踪每个角色并进行替换之外,是否还有我缺少的任何功能或过程?以下是我正在使用的各种示例的一小部分示例,第一行是XML字符串值,以下行是我尝试生成的基本文本,并输出到文本文件.

<string>/iTunes/iTunes%20Music/Droit%20devant/L'odysse%CC%81e.mp3</string>
Run Code Online (Sandbox Code Playgroud)

/ iTunes/iTunes音乐/ Droit devant/L'odyssée.mp3

<string>A%CC%80%20la%20Pe%CC%82che</string>
Run Code Online (Sandbox Code Playgroud)

ÀlaPêche

<string>%D0%97%D0%B0%D0%BF%D0%BE%D0%BC%D0%B8%D0%BD%D0%B0%D0%B8%CC%86</string>
Run Code Online (Sandbox Code Playgroud)

Запоминай

<string>%CE%9A%CE%BF%CC%81%CF%84%CF%83%CC%8C%CE%B1%CF%81%CE%B9</string>
Run Code Online (Sandbox Code Playgroud)

Κότσ̌αρι

对于某些人来说,最后一个可能无法正常显示,因为过度训练的hacek/caron.

提前感谢任何建议或线索

html xml xslt unicode percent-encoding

2
推荐指数
1
解决办法
1843
查看次数