05-02-2007
Jesus that was fast. I was spending hours on this yesterday trying to figure it out and you did it in a minute. So let me just go through this so I understand:
sed "s/:[^:]*$//;s/.*://" file
so 's/' puts it in select mode
1.
:[^:]*$ here's the confusing bit. So what does this mean? Here's me guessing.
Choose ':' and any character at the beginning of ':' when there are 0 or more occurrences of the preceding character before the end of the line??? I'm sure what I said is wrong but that's a guess.
2.
//; keep doing this on each line till the end of the file?
3.
s/.*:// I think I get this bit. This means any character before the next ':' right?
Help out a noob, please.
Oh, and the first line you gave me gives up to the third ':'. I just want the words before the first ':' for that bit.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hey all,
i was just wondering if it was possible to to get data from user input , and parse it through sed to remove or add what that user has entered into a flat file?
do i need awk ?
any help is greatly appreciated
~shan2on (2 Replies)
Discussion started by: shan2on
2 Replies
2. Shell Programming and Scripting
hi all,
i want to display output of sar, whichever idle time is less than 30%..i want to add HI and BYE at the starting and ending of the line.
For an example:
sar
Linux 2.6.9-78.0.1.ELsmp (hostname) 07/10/2009
07:10:01 AM CPU %user %nice %system %iowait %idle... (7 Replies)
Discussion started by: raghur77
7 Replies
3. Shell Programming and Scripting
1.56.253.48 - - "GET "
1.6.253.48 - - "GET "
1.65.253.48 - - "GET "
1.65.253.48 - - "GET "
1.63.53.48 - - "GET "
1.65.253.48 - - "GET "
1.16.23.48 - - "GET "
1.64.25.48 - - "GET "
need command which give the output
1.6.253.48 - 09/Nov/2009:07:02:24
1.65.253.48 -... (7 Replies)
Discussion started by: sagar_evc
7 Replies
4. Shell Programming and Scripting
Hello,
I'm trying to select, or well put the PID that is given by fuser to a var.. It has a wierd format and I somehow can't get it working, any awk/sed experts about?
PID=`fuser $file | awk/sed....?`
if ; then
kill $PID
fi
Greetings and thanks for all your awesome help in advance! (4 Replies)
Discussion started by: TehOne
4 Replies
5. Shell Programming and Scripting
Hi,
In one of my scripts, I am using sed to do an expression replacement. The code in the script is as under
sed "s|MY_INP_Lab=""|MY_INP_Lab="${2}"|" file1, where $2=xyz_abc_mbk
The EXPECTED output is in file1, all the instances ofMY_INP_Lab="" shall be replaced by... (2 Replies)
Discussion started by: vivekmattar
2 Replies
6. Shell Programming and Scripting
Hi all!
I was wondering if anyone could help suggest some solutions to an issue i'm having using the Sed command. I'm still a relative novice at this, but slowly learning and enjoying the power of batch processing.
I am using Sed to extract values from a .txt file containing hundreds of... (2 Replies)
Discussion started by: StudentFitz
2 Replies
7. Shell Programming and Scripting
Hi expert,
i need URGENT help in bash shell scripting using sed:
i woud like to search for the word XMLRPC which is at theend of the line below in up2date file. Once found or match
serverURL=https://redhat.com/XMLRPC
replace with myserver.com like this
... (1 Reply)
Discussion started by: lamoul
1 Replies
8. UNIX for Dummies Questions & Answers
Hi All,
I am looking for a simple concise solution most likely using sed to process the following 4 rows of data from the same record and only keeps it if the second record satisfy certain critea such as surname matches up to smith or jackson:
John (firstname)
Smith (surname) ... (21 Replies)
Discussion started by: gjackson123
21 Replies
9. Shell Programming and Scripting
I would like to recover the data from 3 text tags.
These three markers are located between the tags specific location <tag1> and </tag1> knowing that they are in many places.
In File.txt:
<tag2>txt2</tag2>
<tag3>txt3</tag3>
<tag4>txt4</tag4>
....
<tag1>
<tag2>txt2</tag2>... (3 Replies)
Discussion started by: Amad
3 Replies
10. Shell Programming and Scripting
I am trying to have the user select two files from a numbered list which will eventually be turned into a variable then combined. This is probably something simple and stupid that I am doing.
clear
echo "Please Select the Show interface status file"
select FILE1 in *;
echo "Please Select the... (3 Replies)
Discussion started by: dis0wned
3 Replies
LEARN ABOUT FREEBSD
atf-sh
ATF-SH(1) BSD General Commands Manual ATF-SH(1)
NAME
atf-sh [-s shell] -- interpreter for shell-based test programs
SYNOPSIS
atf-sh script
DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library.
atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter-
preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not
use any non-standard extensions.
The following options are available:
-s shell Specifies the shell to use instead of the value provided by ATF_SHELL.
ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes.
ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes.
ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a
specific interpreter.
EXAMPLES
Scripts using atf-sh(3) should start with:
#! /usr/bin/env atf-sh
Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode
the path to atf-sh in the script and then use the -s option afterwards as a single parameter:
#! /path/to/bin/atf-sh -s/bin/bash
ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts.
SEE ALSO
atf-sh(3)
BSD
September 27, 2014 BSD