Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
11-18-2010, 10:56 PM
#1
Senior Member
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Rep:
Omit specified characters from the output of a command
After typing "man cut" in my terminal I can't seem to find this answer.
I am trying to write several shell scripts and want to remove the 'lp:<package name>' from the beginning of each line of the output of "bzr ls" as well as any notices at the beginning of the output, leaving only file and folder paths.
However, I can't seem to figure out how to do it. Can anybody help me?
Last edited by Kenny_Strawn; 11-18-2010 at 11:20 PM .
11-19-2010, 01:00 AM
#2
Senior Member
Registered: Jan 2003
Posts: 2,786
I don't have bzr on my system. If you post some of the command's output, I might be able to help.
11-19-2010, 01:30 AM
#3
Senior Member
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Original Poster
Rep:
This is the full output of 'bzr ls -R lp:unity', for example:
Code:
lp:unity/.bzrignore
lp:unity/AUTHORS
lp:unity/CMakeLists.txt
lp:unity/COPYING
lp:unity/COPYING.LGPL
lp:unity/ChangeLog
lp:unity/README
lp:unity/cmake/
lp:unity/cmake/vala/
lp:unity/cmake/vala/FindVala.cmake
lp:unity/cmake/vala/ParseArguments.cmake
lp:unity/cmake/vala/README.rst
lp:unity/cmake/vala/ValaPrecompile.cmake
lp:unity/cmake/vala/ValaVersion.cmake
lp:unity/com.canonical.Unity.gschema.xml
lp:unity/config.h.cmake
lp:unity/libunity/
lp:unity/libunity/CMakeLists.txt
lp:unity/libunity/chrome-handler.vala
lp:unity/libunity/drag-controller.vala
lp:unity/libunity/drag-view.vala
lp:unity/libunity/entry.vala
lp:unity/libunity/icon-postprocessor.vala
lp:unity/libunity/prism-handler.vala
lp:unity/libunity/quicklist-rendering.vala
lp:unity/libunity/shell.vala
lp:unity/libunity/theme.vala
lp:unity/libunity/unity-appinfo-manager.vala
lp:unity/libunity/unity-cairo-canvas.vala
lp:unity/libunity/unity-expanding-bin.vala
lp:unity/libunity/unity-favorites.vala
lp:unity/libunity/unity-io.vala
lp:unity/libunity/unity-layered-bin.vala
lp:unity/libunity/unity-pixbuf-cache.vala
lp:unity/libunity/unity-place-activation.vala
lp:unity/libunity/unity-place-browser.vala
lp:unity/libunity/unity-place-renderer.vala
lp:unity/libunity/unity-place.vala
lp:unity/libunity/unity-stripe-texture.vala
lp:unity/libunity/unity.pc.cmake
lp:unity/libunity/webapp-fetcher.vala
lp:unity/po/
lp:unity/po/LINGUAS
lp:unity/po/POTFILES.in
lp:unity/po/POTFILES.skip
lp:unity/po/ar.po
lp:unity/po/bg.po
lp:unity/po/cs.po
lp:unity/po/da.po
lp:unity/po/de.po
lp:unity/po/el.po
lp:unity/po/es.po
lp:unity/po/fi.po
lp:unity/po/fr.po
lp:unity/po/he.po
lp:unity/po/hi.po
lp:unity/po/hr.po
lp:unity/po/hu.po
lp:unity/po/it.po
lp:unity/po/ja.po
lp:unity/po/ko.po
lp:unity/po/nb.po
lp:unity/po/nl.po
lp:unity/po/pl.po
lp:unity/po/pt.po
lp:unity/po/pt_BR.po
lp:unity/po/ro.po
lp:unity/po/ru.po
lp:unity/po/sk.po
lp:unity/po/sl.po
lp:unity/po/sr.po
lp:unity/po/sv.po
lp:unity/po/th.po
lp:unity/po/tr.po
lp:unity/po/unity.pot
lp:unity/po/zh_CN.po
lp:unity/po/zh_TW.po
lp:unity/resources/
lp:unity/resources/2indicate_54x54.png
lp:unity/resources/3indicate_54x54.png
lp:unity/resources/4indicate_54x54.png
lp:unity/resources/bfb.png
lp:unity/resources/focused_indicator.png
lp:unity/resources/round_corner_50x50.png
lp:unity/resources/round_corner_54x54.png
lp:unity/resources/round_outline_50x50.png
lp:unity/resources/round_outline_54x54.png
lp:unity/resources/round_shine_54x54.png
lp:unity/resources/running_indicator.png
lp:unity/services/
lp:unity/services/CMakeLists.txt
lp:unity/services/com.canonical.Unity.Panel.Service.service.cmake
lp:unity/services/panel-main.c
lp:unity/services/panel-service.c
lp:unity/services/panel-service.h
lp:unity/src/
lp:unity/src/BamfLauncherIcon.cpp
lp:unity/src/BamfLauncherIcon.h
lp:unity/src/FavoriteStore.cpp
lp:unity/src/FavoriteStore.h
lp:unity/src/FavoriteStoreGSettings.cpp
lp:unity/src/FavoriteStoreGSettings.h
lp:unity/src/IndicatorObjectEntryProxy.h
lp:unity/src/IndicatorObjectEntryProxyRemote.cpp
lp:unity/src/IndicatorObjectEntryProxyRemote.h
lp:unity/src/IndicatorObjectFactory.h
lp:unity/src/IndicatorObjectFactoryRemote.cpp
lp:unity/src/IndicatorObjectFactoryRemote.h
lp:unity/src/IndicatorObjectProxy.h
lp:unity/src/IndicatorObjectProxyRemote.cpp
lp:unity/src/IndicatorObjectProxyRemote.h
lp:unity/src/Launcher.cpp
lp:unity/src/Launcher.h
lp:unity/src/LauncherController.cpp
lp:unity/src/LauncherController.h
lp:unity/src/LauncherIcon.cpp
lp:unity/src/LauncherIcon.h
lp:unity/src/LauncherModel.cpp
lp:unity/src/LauncherModel.h
lp:unity/src/PanelHomeButton.cpp
lp:unity/src/PanelHomeButton.h
lp:unity/src/PanelIndicatorObjectEntryView.cpp
lp:unity/src/PanelIndicatorObjectEntryView.h
lp:unity/src/PanelIndicatorObjectView.cpp
lp:unity/src/PanelIndicatorObjectView.h
lp:unity/src/PanelView.cpp
lp:unity/src/PanelView.h
lp:unity/src/PluginAdapter.cpp
lp:unity/src/PluginAdapter.h
lp:unity/src/QuicklistView.cpp
lp:unity/src/QuicklistView.h
lp:unity/src/SimpleLauncherIcon.cpp
lp:unity/src/SimpleLauncherIcon.h
lp:unity/src/StaticCairoText.cpp
lp:unity/src/StaticCairoText.h
lp:unity/src/Tooltip.cpp
lp:unity/src/Tooltip.h
lp:unity/src/unity.cpp
lp:unity/src/unity.h
lp:unity/tests/
lp:unity/tests/CMakeLists.txt
lp:unity/tests/TestPanel.cpp
lp:unity/tests/unit/
lp:unity/tests/unit/TestFavoriteStoreGSettings.cpp
lp:unity/tests/unit/TestMain.cpp
lp:unity/tests/unit/TestPanelService.cpp
lp:unity/tools/
lp:unity/tools/build-compiz-glib
lp:unity/tools/makebootchart.py
lp:unity/tools/migrate_favorites.py
lp:unity/unity-private/
lp:unity/unity-private/application.vala
lp:unity/unity-private/gesture/
lp:unity/unity-private/gesture/gesture-dispatcher-xcb-glu.vala
lp:unity/unity-private/gesture/gesture-dispatcher-xcb-glue.c
lp:unity/unity-private/gesture/gesture-dispatcher-xcb.vala
lp:unity/unity-private/gesture/gesture-dispatcher.vala
lp:unity/unity-private/gesture/gesture-event.vala
lp:unity/unity-private/gesture/gesture.c
lp:unity/unity-private/gesture/gesture.h
lp:unity/unity-private/launcher/
lp:unity/unity-private/launcher/application-controller.vala
lp:unity/unity-private/launcher/launcher.vala
lp:unity/unity-private/launcher/quicklist-check-menu-item.vala
lp:unity/unity-private/launcher/quicklist-controller.vala
lp:unity/unity-private/launcher/quicklist-image-menu-item.vala
lp:unity/unity-private/launcher/quicklist-menu-item.vala
lp:unity/unity-private/launcher/quicklist-radio-menu-item.vala
lp:unity/unity-private/launcher/quicklist-seperator-menu-item.vala
lp:unity/unity-private/launcher/quicklist-view.vala
lp:unity/unity-private/launcher/scroller-controller.vala
lp:unity/unity-private/launcher/scroller-model.vala
lp:unity/unity-private/launcher/scroller-view.vala
lp:unity/unity-private/launcher/scrollerchild-controller.vala
lp:unity/unity-private/launcher/scrollerchild.vala
lp:unity/unity-private/panel/
lp:unity/unity-private/panel/panel-background.vala
lp:unity/unity-private/panel/panel-divider.vala
lp:unity/unity-private/panel/panel-home-button.vala
lp:unity/unity-private/panel/panel-indicator-background.vala
lp:unity/unity-private/panel/panel-indicator-bar.vala
lp:unity/unity-private/panel/panel-indicator-model.vala
lp:unity/unity-private/panel/panel-indicator-object-entry-view.vala
lp:unity/unity-private/panel/panel-indicator-object-view.vala
lp:unity/unity-private/panel/panel-menu-manager.vala
lp:unity/unity-private/panel/panel-menubar.vala
lp:unity/unity-private/panel/panel-tray.vala
lp:unity/unity-private/panel/panel-view.vala
lp:unity/unity-private/panlp:unity/unity-private/places/
lp:unity/unity-private/places/places-button.vala
lp:unity/unity-private/places/places-controller.vala
lp:unity/unity-private/places/places-default-renderer-group.vala
lp:unity/unity-private/places/places-default-renderer-tiles.vala
lp:unity/unity-private/places/places-default-renderer.vala
lp:unity/unity-private/places/places-folder-browser-renderer.vala
lp:unity/unity-private/places/places-place-bar.vala
lp:unity/unity-private/places/places-place-entry-scroller-child.vala
lp:unity/unity-private/places/places-place-entry-view.vala
lp:unity/unity-private/places/places-place-entry.vala
lp:unity/unity-private/places/places-place-home-renderer.vala
lp:unity/unity-private/places/places-place-home.vala
lp:unity/unity-private/places/places-place-model.vala
lp:unity/unity-private/places/places-place-search-bar.vala
lp:unity/unity-private/places/places-place-search-entry.vala
lp:unity/unity-private/places/places-place-search-extra-action.vala
lp:unity/unity-private/places/places-place-search-navigation.vala
lp:unity/unity-private/places/places-place-search-sections-bar.vala
lp:unity/unity-private/places/places-place-view.vala
lp:unity/unity-private/places/places-place.vala
lp:unity/unity-private/places/places-trash-controller.vala
lp:unity/unity-private/places/places-view.vala
lp:unity/unity-private/places/places-volume-child-controller.vala
lp:unity/unity-private/places/places-volume-controller.vala
lp:unity/unity-private/testing/
lp:unity/unity-private/testing/background.vala
lp:unity/unity-private/testing/object-registry.vala
lp:unity/unity-private/testing/perf-logger.vala
lp:unity/unity-private/testing/test-director.vala
lp:unity/unity-private/testing/test-utils.vala
lp:unity/unity-private/testing/test-window.vala
lp:unity/unity-private/unity-quirks.vala
lp:unity/unity-private/unity-utils.c
lp:unity/unity-private/unity-utils.h
lp:unity/unity-private/unity.vala
lp:unity/unity-private/utils.vala
lp:unity/unityshell.xml.in
lp:unity/vala_tests/
lp:unity/vala_tests/ui/
lp:unity/vala_tests/ui/Makefile.am
lp:unity/vala_tests/ui/data/
lp:unity/vala_tests/ui/data/Makefile.am
lp:unity/vala_tests/ui/data/quicklist_controller_show_label.png
lp:unity/vala_tests/ui/data/quicklist_shown_on_hover.png
lp:unity/vala_tests/ui/test-automate.vala
lp:unity/vala_tests/ui/test-const.vapi
lp:unity/vala_tests/ui/test-home-button.vala
lp:unity/vala_tests/ui/test-indicators.vala
lp:unity/vala_tests/ui/test-quicklist.vala
lp:unity/vala_tests/ui/test-ui.vala
lp:unity/vala_tests/unit/
lp:unity/vala_tests/unit/Makefile.am
lp:unity/vala_tests/unit/data/
lp:unity/vala_tests/unit/data/Makefile.am
lp:unity/vala_tests/unit/data/applications/
lp:unity/vala_tests/unit/data/applications/ubuntu-about.desktop
lp:unity/vala_tests/unit/data/place0.badplace
lp:unity/vala_tests/unit/data/place0.place
lp:unity/vala_tests/unit/data/place1.badplace
lp:unity/vala_tests/unit/data/place1.place
lp:unity/vala_tests/unit/data/test_desktop_file.desktop
lp:unity/vala_tests/unit/test-appinfo-manager.vala
lp:unity/vala_tests/unit/test-const.vapi
lp:unity/vala_tests/unit/test-dbusmenu-quicklists.vala
lp:unity/vala_tests/unit/test-io.vala
lp:unity/vala_tests/unit/test-launcher.vala
lp:unity/vala_tests/unit/test-panel-indicator-object-entry-view.vala
lp:unity/vala_tests/unit/test-panel-indicator-object-view.vala
lp:unity/vala_tests/unit/test-place-browser.vala
lp:unity/vala_tests/unit/test-place.vala
lp:unity/vala_tests/unit/test-places-place-file-model.vala
lp:unity/vala_tests/unit/test-places-place.vala
lp:unity/vala_tests/unit/test-places.vala
lp:unity/vala_tests/unit/test-unit.vala
lp:unity/vala_tests/unit/test-unity-pixbuf-cache.vala
lp:unity/vapi/
lp:unity/vapi/Makefile.am
lp:unity/vapi/config.vapi
lp:unity/vapi/dee-1.0.deps
lp:unity/vapi/dee-1.0.vapi
lp:unity/vapi/unity-const.vapi
I want to be able to cut out the 'lp:unity' from the beginning of every line.
This is just a test of the command, though; I really am creating a shell script and the data bzr is operating on in the script is a variable.
Last edited by Kenny_Strawn; 11-19-2010 at 01:32 AM .
Reason: Removed unnecessary newlines in output of command
11-19-2010, 02:15 AM
#4
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
Code:
echo "$var" | awk '/^lp:unity/{sub(/^lp:unity/,""); print}'
where var contains the output of bzr ls. This also removes any header line, provided that only the ones you want to keep begin with "lp:unity".
11-19-2010, 02:52 AM
#5
Senior Member
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Original Poster
Rep:
Okay, thank you.
11-19-2010, 03:12 AM
#6
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007
If you are certain the output looks as in post #3 for all lines:
Code:
bzr ls -R lp:unity | cut -c9-
11-19-2010, 04:07 AM
#7
Senior Member
Registered: May 2005
Posts: 4,481
Quote:
Originally Posted by
Kenny_Strawn
After typing "man cut" in my terminal I can't seem to find this answer.
...
How about first answering the question: "What is the
delimiter I am going to use in 'cut' command ?" ?
The relevant excerpt is:
Code:
1 CUT(1) User Commands CUT
1 (1)
2
3
4
5 NAME
6 cut - remove sections from each line of files
7
8 SYNOPSIS
9 cut OPTION... [FILE]...
10
11 DESCRIPTION
12 Print selected parts of lines from each FILE to standard output.
13
14 Mandatory arguments to long options are mandatory for short options too.
15
16 -b, --bytes=LIST
17 select only these bytes
18
19 -c, --characters=LIST
20 select only these characters
21
22 -d, --delimiter=DELIM
23 use DELIM instead of TAB for field delimiter
, so, did you read the very first 23 lines of the manpage, and the 23 lines include blank lines too.
All times are GMT -5. The time now is 08:29 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News