Sponsored Content
Top Forums Shell Programming and Scripting Using sed to execute multiple commands Post 302831253 by exm on Wednesday 10th of July 2013 02:40:57 PM
Old 07-10-2013
Using sed to execute multiple commands

Let's say I have a file called test.out. In this file I want to do the following:
1. Search for DIP-10219 and with this:
2. Remove everything in front of cn=
3. Remove everything after *com
4. Remove duplicate lines
5. Replace ( with \(
6. Replace ) with \)

For 1-3 I have figured out this code:
Code:
sed -rn '/DIP-10219/ s/^.*[^,](cn=.*com).*$/\1/p' test.out

However, I can't figure out how to execeute 4-6 using one sed command. Any thoughts?

Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multiple sed commands

hello! I have a few sed commands sed '/^$/d' < $1 > tmp.t sed '/^ \{3,\}/d' < tmp.t > tmp1.txt ..... how can I write them in a single line? sed '/^$/d' < $1 > | '/^ \{3,\}/d' < $1 > tmp1.txt any idea? thanks. (5 Replies)
Discussion started by: george_
5 Replies

2. Shell Programming and Scripting

how do i get my script to execute multiple commands?

New to shell scripting. I can't get my script to execute multiple commands. Here's the code. It's a menu script. #!/bin/ksh clear print "SDE MENU" PS3="SDE MENU, enter choice:" select clean_menu in "tasdedev instance 5151" "orkindev instance 5155" "tasdetst instance 5157" "orkinsys... (1 Reply)
Discussion started by: hvincent
1 Replies

3. Shell Programming and Scripting

Can Xargs execute multiple commands of evry input file

Hello , I am trying to print the footer of evry file in the given directory with xargs command like follows ls -1 | xargs -I {} gzcat {} | tail -1 now problem with this is only last file foooter is getting printed as " | tail -1 " is getting executed for the last file. I know this can... (4 Replies)
Discussion started by: nilesrex
4 Replies

4. Shell Programming and Scripting

Execute multiple commands in a find

I am checking that a file is older than a reference file that I build with a touch command before processing it. If it is not old enough, I want to sleep for an hour and check again. My problem is if it is old enough to process, I want to exit when I am done, but I cannot find a way to exit... (2 Replies)
Discussion started by: prismtx
2 Replies

5. UNIX for Advanced & Expert Users

How to execute multiple unix commands in one session from java

Hi, Iam trying to code in java and wanted to run the commands in the Unix remote servers. I have the following code to run multiple GREP commands in a single session. But when i execute this, the first command executes successfully, whereas from the next line it says "Exception Occured... (1 Reply)
Discussion started by: gravi2020
1 Replies

6. UNIX for Dummies Questions & Answers

cron used to execute multiple commands

have to run multiple commands at a specified time by the user... (3 Replies)
Discussion started by: hemaa
3 Replies

7. Shell Programming and Scripting

connect to multiple servers using SSH and execute commands

Requirement: Run a shell script with below inputs file name checksum path the script should go to multiple servers (around 35) and verify the input cksum and if there is a mismatch display a simple message to the user that cksum verification failed. host details, user id /... (1 Reply)
Discussion started by: amicableperson
1 Replies

8. Shell Programming and Scripting

How to execute multiple commands in one shot?

for example: I'm greping the process where i can get the location of the file $ ps -ef | grep LLAWP | awk {'print $9'} | tail -1 /Hostname/ihs/INSTANCE2/conf/WebAgent.conf then I need to display second line of WebAgent.conf file: $ cat /Hostname/ihs/INSTANCE1/conf/WebAgent.conf | head... (2 Replies)
Discussion started by: raghur77
2 Replies

9. Shell Programming and Scripting

Ssh multiple hops to execute commands with arguments

Hi I need to write a script to ssh through several hops (e.g. HostA-HostB-HostC-HostD), where Host A does not have direct assess to HostC ; HostB cannot access HostD directly. when I ssh 3 hops and run command with arg1, arg2 and redirect the output to a file, e.g. HostA> ssh -t HostB ssh -t... (3 Replies)
Discussion started by: chiensh
3 Replies

10. UNIX for Beginners Questions & Answers

Use sed commands on multiple lines

I have a text file and i want to run 3 sed commands for the lines entered by the user using perl script. I am doing this manually till now. need some help with this The sed commands I have to use are : sed -i "s/{+//" error.txt sed -i "s/+}//" error.txt sed -i "s/\//g" error.txt... (5 Replies)
Discussion started by: utkarshkhanna44
5 Replies
STRIP(1)						    BSD General Commands Manual 						  STRIP(1)

NAME
strip -- discard information from ELF objects SYNOPSIS
strip [-d | -g | -S | --strip-debug] [-h | --help] [--only-keep-debug] [-o outputfile | --output-file=outputfile] [-p | --preserve-dates] [-s | --strip-all] [--strip-unneeded] [-w | --wildcard] [-x | --discard-all] [-I format | --input-target=format] [-K symbol | --keep-symbol=symbol] [-N symbol | --strip-symbol=symbol] [-O format | --output-target=format] [-R sectionname | --remove-section=sectionname] [-V | --version] [-X | --discard-locals] file ... DESCRIPTION
The strip utility is used to discard information from ELF objects. The strip utility supports the following options: -d | -g | -S | --strip-debug Remove debugging symbols only. -h | --help Print a help message and exit. --only-keep-debug Remove all content except that which would be used for debugging. -o outputfile | --output-file=outputfile Write the stripped object to file outputfile. The default behaviour is to modify objects in place. -p | --preserve-dates Preserve the object's access and modification times. -s | --strip-all Remove all symbols. --strip-unneeded Remove all symbols not needed for further relocation processing. -w | --wildcard Use shell-style patterns to name symbols. The following meta-characters are recognized in patterns: ! If this is the first character of the pattern, invert the sense of the pattern match. * Matches any string of characters in a symbol name. ? Matches zero or one character in a symbol name. [ Mark the start of a character class. Remove the special meaning of the next character in the pattern. ] Mark the end of a character class. -x | --discard-all Discard all non-global symbols. -I format | --input-target=format These options are accepted, but are ignored. -K symbol | --keep-symbol=symbol Keep the symbol symbol even if it would otherwise be stripped. This option may be specified multiple times. -N symbol | --strip-symbol=symbol Remove the symbol symbol even if it would otherwise have been kept. This option may be specified multiple times. -O format | --output-target=format Set the output file format to format. For the full list of supported formats, please see the documentation for function elftc_bfd_find_target(3). -R sectionname | --remove-section=sectionname Remove the section named by the argument sectionname. This option may be specified multiple times. -V | --version Print a version identifier and exit. -X | --discard-locals Remove compiler-generated local symbols. DIAGNOSTICS
The strip utility exits 0 on success, and >0 if an error occurs. SEE ALSO
ar(1), elfcopy(1), ld(1), mcs(1), elf(3), elftc_bfd_find_target(3), fnmatch(3) BSD
September 17, 2011 BSD
All times are GMT -4. The time now is 04:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy