首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用新行替换逗号,以及如何用linux命令删除“commands”

如何用新行替换逗号,以及如何用linux命令删除“commands”
EN

Stack Overflow用户
提问于 2022-09-05 10:42:07
回答 1查看 60关注 0票数 0

使用下面的命令集,我无法从粘贴在本文中的文本文件中删除"mixins“条目。应删除一行中只包含“the”的行,而包含“the”以上的行则应保留。我还想从文件中的每一行末尾删除逗号。

代码语言:javascript
复制
# SED Commands to remove comma from the line ending
sed -i -e $'s/,/\\\n/g' bundle/homepage.txt
sed -i -e $'s/,/\\\n/g' bundle/category.txt
sed -i -e $'s/,/\\\n/g' bundle/product.txt
sed -i -e $'s/,/\\\n/g' bundle/cart.txt
sed -i -e $'s/,/\\\n/g' bundle/checkout.txt
sed -i -e $'s/,/\\\n/g' bundle/cmst.txt

# SED Commands to remove mixins and remove blank line
sed -i -e 's/mixins\!.*$//g' bundle/homepage.txt
sed -i -e 's/mixins\!.*$//g' bundle/category.txt
sed -i -e 's/mixins\!.*$//g' bundle/product.txt
sed -i -e 's/mixins\!.*$//g' bundle/cart.txt
sed -i -e 's/mixins\!.*$//g' bundle/checkout.txt
sed -i -e 's/mixins\!.*$//g' bundle/cms.txt

这里是文本文件,它要求我们Magento存储的主页需要-js依赖项。

代码语言:javascript
复制
"mixins",
"jquery",
"Magento_PageCache/js/form-key-provider",
"domReady",
"domReady!",
"text",
"mage/ie-class-fixer",
"underscore",
"mage/template",
"text!js-translation.json",
"Magento_Translation/js/mage-translation-dictionary",
"mage/utils/wrapper",
"Magento_ReCaptchaWebapiUi/js/jquery-mixin",
"mixins!jquery",
"mage/common",
"Magento_Ui/js/lib/registry/registry",
"Amazon_Pay/js/model/amazon-pay-config",
"WeltPixel_GoogleTagManager/js/weltpixel_gtm",
"js/mute-migrate",
"mage/smart-keyboard-handler",
"Swissup_Navigationpro/js/rtl",
"Swissup_Navigationpro/js/nowrap",
"Magento_Persistent/js/view/customer-data-mixin",
"Swissup_Easytabs/js/mixin/collapsible",
"js/mixin/collapsible/stop-tab-scroll-into-viewport",
"knockoutjs/knockout",
"Magento_Customer/js/section-config",
"mage/url",
"mage/storage",
"text!ui/template/modal/modal-popup.html",
"text!ui/template/modal/modal-slide.html",
"text!ui/template/modal/modal-custom.html",
"knockoutjs/knockout-es5",
"Swissup_Gdpr/js/action/accept-cookie-groups",
"Swissup_Gdpr/js/action/register-unknown-cookie",
"jquery/z-index",
"jquery/jquery.cookie",
"jquery/ui-modules/version",
"mixins!jquery/ui-modules/version",
"jquery/ui-modules/widget",
"mage/apply/scripts",
"js/mixin/apply/scripts-lazy",
"mixins!mage/apply/scripts",
"mage/apply/main",
"mage/mage",
"Magento_Theme/js/theme",
"mage/translate",
"mage/cookies",
"Magento_Ui/js/lib/knockout/extender/observable_array",
"mixins!Magento_Ui/js/lib/knockout/extender/observable_array",
"Magento_Ui/js/lib/key-codes",
"matchMedia",
"js/lib/sticky-kit",
"Magento_Ui/js/lib/view/utils/dom-observer",
"mixins!Magento_Ui/js/lib/view/utils/dom-observer",
"Magento_Ui/js/lib/view/utils/bindings",
"mixins!Magento_Ui/js/lib/view/utils/bindings",
"Magento_Ui/js/lib/core/events",
"Magento_Ui/js/lib/knockout/extender/bound-nodes",
"Magento_Ui/js/lib/view/utils/async",
"js/argento-base",
"mixins!Magento_Ui/js/lib/knockout/extender/bound-nodes",
"jquery/jquery.storageapi.min",
"jquery/jquery-storageapi",
"Amazon_Pay/js/model/storage",
"Magento_Customer/js/customer-data",
"mixins!Magento_Customer/js/customer-data",
"Swissup_Gdpr/js/model/cookie-manager",
"Swissup_Gdpr/js/model/cookie-blocker",
"jquery/jquery-migrate",
"knockoutjs/knockout-repeat",
"knockoutjs/knockout-fast-foreach",
"jquery/ui-modules/form",
"mixins!jquery/ui-modules/form",
"jquery/ui-modules/ie",
"mixins!jquery/ui-modules/ie",
"jquery/ui-modules/keycode",
"mixins!jquery/ui-modules/keycode",
"jquery/ui-modules/data",
"mixins!jquery/ui-modules/data",
"jquery/ui-modules/disable-selection",
"mixins!jquery/ui-modules/disable-selection",
"jquery/ui-modules/focusable",
"mixins!jquery/ui-modules/focusable",
"mage/utils/strings",
"mixins!mage/utils/strings",
"mage/utils/objects",
"mixins!mage/utils/objects",
"jquery/ui-modules/labels",
"mixins!jquery/ui-modules/labels",
"jquery/ui-modules/jquery-patch",
"mixins!jquery/ui-modules/jquery-patch",
"jquery/ui-modules/plugin",
"mixins!jquery/ui-modules/plugin",
"jquery/ui-modules/safe-active-element",
"mixins!jquery/ui-modules/safe-active-element",
"jquery/ui-modules/safe-blur",
"mixins!jquery/ui-modules/safe-blur",
"jquery/ui-modules/scroll-parent",
"mixins!jquery/ui-modules/scroll-parent",
"jquery/ui-modules/tabbable",
"mixins!jquery/ui-modules/tabbable",
"jquery/ui-modules/unique-id",
"mixins!jquery/ui-modules/unique-id",
"jquery/ui-modules/core",
"Magento_Ui/js/modal/modal",
"js/argento-custom",
"Magento_Ui/js/modal/confirm",
"mage/dataPost",
"js/argento-sticky",
"mage/collapsible",
"mixins!mage/collapsible",
"js/argento-theme",
"Magento_Ui/js/lib/knockout/bindings/mage-init",
"mixins!Magento_Ui/js/lib/knockout/bindings/mage-init",
"Magento_Ui/js/lib/knockout/bindings/datepicker",
"mixins!Magento_Ui/js/lib/knockout/bindings/datepicker",
"Magento_Ui/js/lib/knockout/bindings/fadeVisible",
"mixins!Magento_Ui/js/lib/knockout/bindings/fadeVisible",
"mage/utils/template",
"mixins!mage/utils/template",
"Magento_Customer/js/model/authentication-popup",
"mage/utils/arrays",
"mixins!mage/utils/arrays",
"mage/utils/compare",
"mixins!mage/utils/compare",
"mage/utils/misc",
"mixins!mage/utils/misc",
"mage/utils/main",
"Magento_Ui/js/lib/core/storage/local",
"WeltPixel_GoogleTagManager/js/weltpixel_persistentlayer",
"Magento_Ui/js/lib/knockout/bindings/optgroup",
"mixins!Magento_Ui/js/lib/knockout/bindings/optgroup",
"text!ui/template/tooltip/tooltip.html",
"Magento_Ui/js/lib/core/class",
"Magento_Ui/js/lib/knockout/template/observable_source",
"mixins!Magento_Ui/js/lib/knockout/template/observable_source",
"Magento_Ui/js/lib/knockout/template/loader",
"mixins!Magento_Ui/js/lib/knockout/template/loader",
"Magento_Ui/js/lib/knockout/template/renderer",
"mixins!Magento_Ui/js/lib/knockout/template/renderer",
"Magento_Ui/js/lib/knockout/bindings/i18n",
"mixins!Magento_Ui/js/lib/knockout/bindings/i18n",
"Magento_Ui/js/lib/knockout/bindings/range",
"mixins!Magento_Ui/js/lib/knockout/bindings/range",
"Magento_Ui/js/lib/knockout/bindings/keyboard",
"mixins!Magento_Ui/js/lib/knockout/bindings/keyboard",
"Magento_Ui/js/lib/knockout/bindings/after-render",
"mixins!Magento_Ui/js/lib/knockout/bindings/after-render",
"Magento_Ui/js/lib/knockout/bindings/autoselect",
"mixins!Magento_Ui/js/lib/knockout/bindings/autoselect",
"Magento_Ui/js/lib/knockout/bindings/outer_click",
"mixins!Magento_Ui/js/lib/knockout/bindings/outer_click",
"Magento_Ui/js/lib/knockout/bindings/collapsible",
"mixins!Magento_Ui/js/lib/knockout/bindings/collapsible",
"Magento_Ui/js/lib/knockout/bindings/bind-html",
"mixins!Magento_Ui/js/lib/knockout/bindings/bind-html",
"Magento_Ui/js/lib/knockout/bindings/tooltip",
"mixins!Magento_Ui/js/lib/knockout/bindings/tooltip",
"Magento_Ui/js/lib/logger/message-pool",
"mixins!Magento_Ui/js/lib/logger/message-pool",
"Magento_Ui/js/lib/logger/levels-pool",
"mixins!Magento_Ui/js/lib/logger/levels-pool",
"Magento_Ui/js/lib/logger/logger",
"mixins!Magento_Ui/js/lib/logger/logger",
"Magento_Ui/js/lib/logger/console-output-handler",
"mixins!Magento_Ui/js/lib/logger/console-output-handler",
"Magento_Ui/js/lib/logger/logger-utils",
"mixins!Magento_Ui/js/lib/logger/logger-utils",
"moment",
"Magento_Ui/js/lib/logger/formatter",
"mixins!Magento_Ui/js/lib/logger/formatter",
"Magento_Ui/js/lib/logger/entry",
"mixins!Magento_Ui/js/lib/logger/entry",
"Magento_Ui/js/lib/logger/entry-factory",
"mixins!Magento_Ui/js/lib/logger/entry-factory",
"Magento_Ui/js/lib/logger/console-logger",
"mixins!Magento_Ui/js/lib/logger/console-logger",
"Magento_Ui/js/lib/knockout/template/engine",
"mixins!Magento_Ui/js/lib/knockout/template/engine",
"Magento_Ui/js/lib/knockout/bindings/scope",
"mixins!Magento_Ui/js/lib/knockout/bindings/scope",
"Magento_Ui/js/lib/knockout/bindings/bootstrap",
"mixins!Magento_Ui/js/lib/knockout/bindings/bootstrap",
"Magento_Ui/js/lib/knockout/bootstrap",
"Swissup_Pagespeed/js/lib/mage/bootstrap",
"mage/loader",
"Magento_PageBuilder/js/widget-initializer",
"Magento_Theme/js/cookie-status",
"Magento_PageCache/js/page-cache",
"mage/dropdowns",
"Magento_Search/js/form-mini",
"mage/trim-input",
"Magento_Ui/js/block-loader",
"mixins!Magento_Ui/js/lib/knockout/bootstrap",
"Magento_Customer/js/block-submit-on-send",
"text!ui/template/block-loader.html",
"Swissup_Ajaxsearch/js/ajaxsearch/results",
"Swissup_Ajaxsearch/js/ajaxsearch/mobile",
"Swissup_Ajaxsearch/js/lib/graphqlize",
"Swissup_Ajaxsearch/js/lib/typeaheadbundle",
"Swissup_Ajaxsearch/js/ajaxsearch",
"Swissup_Navigationpro/js/touch",
"mixins!jquery/ui-modules/widget",
"jquery/ui-modules/widgets/tabs",
"mage/tabs",
"Magento_Ui/js/core/renderer/types",
"mixins!Magento_Ui/js/core/renderer/types",
"Magento_Ui/js/core/renderer/layout",
"mixins!Magento_Ui/js/core/renderer/layout",
"Magento_Ui/js/core/app",
"mixins!Magento_Ui/js/lib/core/storage/local",
"bloodhound",
"typeahead.js",
"jquery/ui-modules/widgets/mouse",
"mixins!jquery/ui-modules/widgets/mouse",
"jquery/ui-modules/widgets/draggable",
"mixins!jquery/ui-modules/widgets/draggable",
"jquery/ui-modules/widgets/resizable",
"mixins!jquery/ui-modules/widgets/resizable",
"jquery/ui-modules/position",
"mixins!jquery/ui-modules/position",
"jquery/ui-modules/widgets/menu",
"mage/menu",
"Swissup_Navigationpro/js/navpro",
"Magento_Ui/js/lib/core/element/links",
"mixins!Magento_Ui/js/lib/core/element/links",
"Magento_Ui/js/lib/core/element/element",
"Magento_Customer/js/invalidation-processor",
"Magento_Ui/js/lib/core/collection",
"Magento_Tax/js/view/checkout/minicart/subtotal/totals",
"Magento_Msrp/js/view/checkout/minicart/subtotal/totals",
"Magento_Checkout/js/view/cart-item-renderer",
"Magento_Catalog/js/view/image",
"Magento_Customer/js/view/customer",
"jquery/jquery.metadata",
"jquery/validate",
"mage/validation",
"mage/validation/validation",
"Magento_Wishlist/js/view/wishlist",
"Swissup_Navigationpro/js/make-vertical-columns",
"jquery/ui-modules/widgets/controlgroup",
"mixins!jquery/ui-modules/widgets/controlgroup",
"StripeIntegration_Payments/js/messages-mixin",
"Magento_Customer/js/invalidation-rules/website-rule",
"Magento_Ui/js/modal/alert",
"Magento_Captcha/js/model/captchaList",
"Magento_Security/js/escaper",
"Magento_Theme/js/view/messages",
"Swissup_Ajaxpro/js/modal-manager",
"Swissup_Ajaxpro/js/ajaxpro",
"Magento_ReCaptchaFrontendUi/js/registry",
"Magento_ReCaptchaFrontendUi/js/ui-messages-mixin",
"jquery/ui-modules/form-reset-mixin",
"mixins!jquery/ui-modules/form-reset-mixin",
"jquery/ui-modules/widgets/checkboxradio",
"mixins!jquery/ui-modules/widgets/checkboxradio",
"jquery/ui-modules/widgets/button",
"mixins!jquery/ui-modules/widgets/button",
"jquery/ui-modules/widgets/dialog",
"mage/dropdown",
"mage/decorate",
"Magento_Ui/js/lib/spinner",
"mage/requirejs/resolver",
"Amazon_Pay/js/amazon-checkout",
"Magento_Catalog/js/product/storage/ids-storage",
"Magento_Catalog/js/product/storage/ids-storage-compare",
"Magento_PaypalCaptcha/js/model/skipRefreshCaptcha",
"Magento_PaypalCaptcha/js/view/checkout/defaultCaptcha-mixin",
"Magento_Ui/js/model/messages",
"mixins!Magento_Ui/js/model/messages",
"Magento_Ui/js/model/messageList",
"mixins!Magento_Ui/js/model/messageList",
"Magento_Customer/js/action/login",
"Magento_Catalog/js/product/query-builder",
"Magento_Catalog/js/product/storage/data-storage",
"Magento_Catalog/js/product/storage/storage-service",
"Magento_Catalog/js/storage-manager",
"Amazon_Pay/js/action/checkout-session-config-load",
"Amazon_Pay/js/amazon-login-button",
"Amazon_Pay/js/view/login-button-wrapper",
"Magento_Captcha/js/action/refresh",
"Magento_Captcha/js/model/captcha",
"Magento_Captcha/js/view/checkout/defaultCaptcha",
"mixins!Magento_Captcha/js/view/checkout/defaultCaptcha",
"Magento_Captcha/js/view/checkout/loginCaptcha",
"Magento_Ui/js/form/adapter/buttons",
"Magento_Ui/js/form/adapter",
"mixins!Magento_Ui/js/form/adapter",
"Magento_Ui/js/form/form",
"Magento_Customer/js/view/authentication-popup",
"Swissup_Ajaxpro/js/modal",
"jquery/ui-modules/jquery-var-for-color",
"mixins!jquery/ui-modules/jquery-var-for-color",
"jquery/ui-modules/vendor/jquery-color/jquery.color",
"mixins!jquery/ui-modules/vendor/jquery-color/jquery.color",
"jquery/ui-modules/effect",
"mixins!jquery/ui-modules/effect",
"jquery/ui-modules/effects/effect-blind",
"Magento_Ui/js/view/messages",
"mixins!Magento_Ui/js/view/messages",
"jquery/ui-modules/effects/effect-fade",
"Magento_Checkout/js/sidebar",
"Magento_Checkout/js/view/minicart"
EN

回答 1

Stack Overflow用户

发布于 2022-09-05 14:41:45

如果您确信要删除的行始终等于"mixins",则可以使用以下命令

代码语言:javascript
复制
grep -v '"mixins",' input_file.txt > output_file.txt

Grep是一个在文件(或流)中筛选行的方便工具,-v选项告诉grep您只想找到与搜索字符串不匹配的行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73608088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档