问题描述
我有一个文件,其中包含许多以字符串px结尾的值。我需要找到所有这些值,用0.43多个它们再次将它们写入带有子串'pt'的文件而不是'px'
如何实现这个?
例如文件中的字符串:
I have a file which contains so many values which ends with a string px. I need to find all those values, multiple them with 0.43 and again write them to the file with the substring 'pt' instead of 'px'
How do I achieve this ??
eg string from the file:
.ClassOne
{
margin: .35em 5px;
overflow: hidden;
padding: 0 1.4em 0 .5em;
position: relative;
text-overflow: ellipsis;
white-space: nowrap;
}
.ClassTwo
{
border: 7px solid #FFF;
border-top-color: #000;
position: absolute;
right: 6px;
top: .95em;
}
.ClassThree
{
bottom: 5px;
height: 1px;
left: 1em;
position: absolute;
right: 2em;
}
查找所有以px结尾的值,并通过乘以0.43将它们转换为点并将它们写回文件。
示例:5px = 2.15pt,-9px = -3.87pt
如何在unix中使用单行命令行实现这一目标?由于我是shell脚本的新手,我需要一些帮助。我所知道的是它可以使用sed -i实现。
To find all the values that ends with px, and convert them to points by multiplying with 0.43 and write them back to the file.
Example: 5px = 2.15pt, -9px = -3.87pt
How to achieve this using a single line command line in unix?? Since I am new to shell scripting, I need some help. All I know is that it can be achieved using sed -i.
推荐答案
这篇关于用于查找,转换和替换文件中的值的Unix脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!