Sponsored Content
Top Forums Shell Programming and Scripting Using sed to delete everything after "space" Post 303011043 by MadeInGermany on Friday 12th of January 2018 10:41:11 AM
Old 01-12-2018
You certainly meant .* not .$ ?
Further, \s is standard in perl (PCRE). And came into the GNU RE but is not a standard in an RE (not portable to a non-GNU sed).
The standard wants a character class
Code:
sed 's/[[:blank:]].*//'

Last but not least you ask to delete everything *after* a space, that would be
Code:
sed 's/\([[:blank:]]\).*/\1/'

The matching blank is marked in a \( \) group, and the \1 restores it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete lines ending in "_;" using sed

I could really use some help with this issue. I'm having a lot of trouble getting my sed command to delete only the lines from my file that end with _; I'm also supposed to carry the leading 'c' down to the next line. The commands I've tried either delete everything or nothing at all. Any help... (12 Replies)
Discussion started by: turbulence
12 Replies

2. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

3. Shell Programming and Scripting

Sed: Delete lines in files that contain other than a-z ,0-9 and "."

Sed: Delete lines in files that contain other than 'a-z' ,'0-9', '.' and '-' Hello, I'm looking for a shell command or maybe a small php loop to delete lines in files.txt (in the same directory) that contain character other then 'a-z' ,'0-9', '.' and '-' All line that have characters like... (4 Replies)
Discussion started by: devlin
4 Replies

4. Shell Programming and Scripting

Unix commands delete all files starting with "X" except "X" itself. HELP!!!!?

im a new student in programming and im stuck on this question so please please HELP ME. thanks. the question is this: enter a command to delete all files that have filenames starting with labtest, except labtest itself (delete all files startign with 'labtest' followed by one or more... (2 Replies)
Discussion started by: soccerball
2 Replies

5. Shell Programming and Scripting

Delete files older than "x" if directory size is greater than "y"

I wrote a script to delete files which are older than "x" days, if the size of the directory is greater than "y" #!/bin/bash du -hs $1 while read SIZE ENTRY do if ; then find $1 -mtime +$2 -exec rm -f {} \; echo "Files older than $2 days deleted" else echo "free Space available"... (4 Replies)
Discussion started by: JamesCarter
4 Replies

6. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

7. Shell Programming and Scripting

awk -sed help : forth . to convert to "space"

Hi Experts, Good day, I am looking for the 6th fields 4th dot (.) to convert into a space in the output. file: tcp 0 0 10.80.110.100 2900 1 10.40.104.6.42769 ESTABLISHED tcp 0 0 10.80.110.100 2900 1 10.40.103.7.38620 ESTABLISHED tcp 0 ... (11 Replies)
Discussion started by: rveri
11 Replies

8. Shell Programming and Scripting

Find "*.c" and "Makefile" and then delete them with one line

find "*.c" and "Makefile" and then delete them with one line (3 Replies)
Discussion started by: yanglei_fage
3 Replies

9. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

10. Shell Programming and Scripting

sed not applying /d "delete line" option

So I'm on an AIX machine. And sed is not applying /d "delete line" option when I also include match word options \< and \> examples... echo cat | sed '/\<cat\>/d'will return cat for some reason echo cat | sed "/\<cat\>/d"will also still return cat. Of course i can just run echo cat... (9 Replies)
Discussion started by: escooter87
9 Replies
SWFDISPLAYITEM(3)							 1							 SWFDISPLAYITEM(3)

The SWFDisplayItem class

INTRODUCTION
SWFDisplayItem. CLASS SYNOPSIS
SWFDisplayItem SWFDisplayItem Methods o void SWFDisplayItem::addAction (SWFAction $action, int $flags) o void SWFDisplayItem::addColor (int $red, int $green, int $blue, [int $a]) o void SWFDisplayItem::endMask (void ) o float SWFDisplayItem::getRot (void ) o float SWFDisplayItem::getX (void ) o float SWFDisplayItem::getXScale (void ) o float SWFDisplayItem::getXSkew (void ) o float SWFDisplayItem::getY (void ) o float SWFDisplayItem::getYScale (void ) o float SWFDisplayItem::getYSkew (void ) o void SWFDisplayItem::move (float $dx, float $dy) o void SWFDisplayItem::moveTo (float $x, float $y) o void SWFDisplayItem::multColor (float $red, float $green, float $blue, [float $a]) o void SWFDisplayItem::remove (void ) o void SWFDisplayItem::rotate (float $angle) o void SWFDisplayItem::rotateTo (float $angle) o void SWFDisplayItem::scale (float $dx, float $dy) o void SWFDisplayItem::scaleTo (float $x, [float $y]) o void SWFDisplayItem::setDepth (int $depth) o void SWFDisplayItem::setMaskLevel (int $level) o void SWFDisplayItem::setMatrix (float $a, float $b, float $c, float $d, float $x, float $y) o void SWFDisplayItem::setName (string $name) o void SWFDisplayItem::setRatio (float $ratio) o void SWFDisplayItem::skewX (float $ddegrees) o void SWFDisplayItem::skewXTo (float $degrees) o void SWFDisplayItem::skewY (float $ddegrees) o void SWFDisplayItem::skewYTo (float $degrees) PHP Documentation Group SWFDISPLAYITEM(3)
All times are GMT -4. The time now is 09:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy