Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Cannot extract libraries using sed Post 303037771 by sand1234 on Tuesday 13th of August 2019 08:14:44 AM
Old 08-13-2019
Hi MadeinGermany,

Thanks for the tips.

The first solution does not work,

Code:
 ./copy_chroot_lib.sh ls echo | sed -n 's#\(/lib\).*#\1#p'
        libselinux.so.1 => /lib
        libc.so.6 => /lib
        libpcre.so.3 => /lib
        libdl.so.2 => /lib
        /lib
        libpthread.so.0 => /lib
        libc.so.6 => /lib
        /lib

While the output from the second solution does not capture only file path, and also captures (0x00...)

Code:
 ./copy_chroot_lib.sh ls echo | sed -n 's#.* => ##p'
/lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f73bfead000)
/lib/x86_64-linux-gnu/libc.so.6 (0x00007f73bfcc3000)
/lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f73bfc4f000)
/lib/x86_64-linux-gnu/libdl.so.2 (0x00007f73bfc49000)
/lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f73bfc28000)
/lib/x86_64-linux-gnu/libc.so.6 (0x00007f2cfa01c000)

I suppose we can exclude the hex value via the following, then capture lines starting with /lib.

Code:
 ./copy_chroot_lib.sh ls echo | sed -E 's#.* => ##;s/[(]0.*//'
        linux-vdso.so.1   <----- should not be included
/lib/x86_64-linux-gnu/libselinux.so.1
/lib/x86_64-linux-gnu/libc.so.6
/lib/x86_64-linux-gnu/libpcre.so.3
/lib/x86_64-linux-gnu/libdl.so.2
        /lib64/ld-linux-x86-64.so.2
/lib/x86_64-linux-gnu/libpthread.so.0
        linux-vdso.so.1
/lib/x86_64-linux-gnu/libc.so.6
        /lib64/ld-linux-x86-64.so.2

Do let me know if you have any better ideas.

Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help! Sed extract a pattern

I am trying to extract "securitySettings" out of line: <a ref ="http://localhost:5654/securitySettings"> using sed as follows: name = `grep "localhost" file.html | sed -n 's/.**\/\(.*)/\">/\1/p'` But it didn't run, seems have some syntax error. Do anybody knows why? Thank you very... (11 Replies)
Discussion started by: zhen
11 Replies

2. Shell Programming and Scripting

SED to extract characters

Hi, Please let me know how do we write a piece of code to extract characters from a line using SED. (2 Replies)
Discussion started by: Shilpi
2 Replies

3. Shell Programming and Scripting

SED to extract characters

Hi, Please let me know how do we write a piece of code to extract characters from a line using SED. (1 Reply)
Discussion started by: Shilpi
1 Replies

4. Shell Programming and Scripting

SED extract XML value

I have the following string: <min-pool-size>2</min-pool-size> When I pipe the string into the following code I am expcting for it to return just the value "2", but its just reurning the whole string. Why?? sed -n '/<min-pool-size>/,/<\/min-pool-size>/p' Outputting:... (13 Replies)
Discussion started by: ArterialTool
13 Replies

5. Shell Programming and Scripting

Extract word using sed

Hello, I am new to sed and am trying to extract a word using sed. for example i have a line "const TotalAmount& getTotalAmount() const; " in the file test.txt I am trying to extract getTotalAmount() from the line. For this i tried cat test.txt | sed -n 's/.*get*\(\)//p But... (8 Replies)
Discussion started by: prasbala
8 Replies

6. Shell Programming and Scripting

sed extract from xml

I have an xml file that generally looks like this: "<row><dnorpattern>02788920</dnorpattern><description/></row><row><dnorpattern>\+ 44146322XXXX</dnorpattern><description/></row><row><dnorpattern>40XXX</dnorpattern><description/></row><row><dnorpattern>11</dn... (4 Replies)
Discussion started by: garboon
4 Replies

7. Shell Programming and Scripting

Extract using sed

Given a file with contents /arch/powerpc/boot/4xx.o > /arch/powerpc/boot/.4xx.o.cmd > /arch/powerpc/boot/addnote 5766a5769 > /arch/powerpc/boot/.addnote.cmd 5768a5772,5773 > /arch/powerpc/boot/bamboo.o > /arch/powerpc/boot/.bamboo.o.cmd 5769a5775,5778 > /arch/powerpc/boot/cpm-serial.o... (8 Replies)
Discussion started by: xerox
8 Replies

8. Shell Programming and Scripting

sed data extract

Hello, I have huge number files in a directory. All files have the data. I want extract data. I want all output write to single csv file. following codes works. Thank you very much for help. sed -n '/.*Content$txtE_Zip" type="text" value="\(*\)" maxlength.*/s//\1/p' *>file1 sed -n... (5 Replies)
Discussion started by: hoo
5 Replies

9. Shell Programming and Scripting

sed to extract all strings

Hi, I have a text file containing 2 lines as follows: I'm trying to extract all the strings following an "AME." The output would be as follows: BUSINESS_UNIT PROJECT_ID ACTIVITY_ID RES_USER1 RESOURCE_ID_FROM ANALYSIS_TYPE BI_DISTRIB_STATUS BUSINESS_UNIT PROJECT_ID ACTIVITY_ID... (5 Replies)
Discussion started by: simpletech369
5 Replies

10. Shell Programming and Scripting

Extract a value using sed (easy)

I have this command to replace the version value from PROGRAM (for example here PROGRAM == player) by NEWVERSION sed "/^ *$PROGRAM:/{N; s/*$/ $NEWVERSION/;}" -i $PRDFILE player: version: V6R2013xD3HF5v1 player_old: version: V6R2013xD3HF5v1 partchecker: version:... (2 Replies)
Discussion started by: jcanale
2 Replies
PMINST(1p)						User Contributed Perl Documentation						PMINST(1p)

NAME
pminst - find modules whose names match this pattern SYNOPSIS
pminst [-s] [-l] [pattern] DESCRIPTION
Without argumnets, show the names of all installed modules. Given a pattern, show all module names that match it. The -l flag will show the full pathname. The -s flag will separate the base directory from @INC from the module portion itself. EXAMPLES
$ pminst (lists all installed modules) $ pminst Carp CGI::Carp Carp $ pminst ^IO:: IO::Socket::INET IO::Socket::UNIX IO::Select IO::Socket IO::Poll IO::Handle IO::Pipe IO::Seekable IO::Dir IO::File $ pminst '(?i)io' IO::Socket::INET IO::Socket::UNIX IO::Select IO::Socket IO::Poll IO::Handle IO::Pipe IO::Seekable IO::Dir IO::File IO Pod::Functions The -s flag provides output with the directory separated by a space: $ pminst -s | sort +1 (lists all modules, sorted by name, but with where they came from) $ oldperl -S pminst -s IO /usr/lib/perl5/i386-linux/5.00404 IO::File /usr/lib/perl5/i386-linux/5.00404 IO::Handle /usr/lib/perl5/i386-linux/5.00404 IO::Pipe /usr/lib/perl5/i386-linux/5.00404 IO::Seekable /usr/lib/perl5/i386-linux/5.00404 IO::Select /usr/lib/perl5/i386-linux/5.00404 IO::Socket /usr/lib/perl5/i386-linux/5.00404 IO /usr/lib/perl5/site_perl LWP::IO /usr/lib/perl5/site_perl LWP::TkIO /usr/lib/perl5/site_perl Tk::HTML::IO /usr/lib/perl5/site_perl Tk::IO /usr/lib/perl5/site_perl IO::Stringy /usr/lib/perl5/site_perl IO::Wrap /usr/lib/perl5/site_perl IO::ScalarArray /usr/lib/perl5/site_perl IO::Scalar /usr/lib/perl5/site_perl IO::Lines /usr/lib/perl5/site_perl IO::WrapTie /usr/lib/perl5/site_perl IO::AtomicFile The -l flag gives full paths: $ filsperl -S pminst -l Thread /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Queue.pm /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Semaphore.pm /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Signal.pm /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Specific.pm /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread.pm AUTHORS and COPYRIGHTS Copyright (C) 1999 Tom Christiansen. Copyright (C) 2006-2008 Mark Leighton Fisher. This is free software; you can redistribute it and/or modify it under the terms of either: (a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or (b) the Perl "Artistic License". (This is the Perl 5 licensing scheme.) Please note this is a change from the original pmtools-1.00 (still available on CPAN), as pmtools-1.00 were licensed only under the Perl "Artistic License". perl v5.10.1 2010-02-22 PMINST(1p)
All times are GMT -4. The time now is 12:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy