Stripping ret of the lines in a file (sed question)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stripping ret of the lines in a file (sed question)
# 1  
Old 02-13-2014
[Solved] Stripping ret of the lines in a file (sed question)

Hi all,

I didn't use SED for 20 years and was never an expert. So my current knowledge is about zero. Please be patient with me. I'm neither a native speaker.

I have a huge dictionary file and want the rest of the lines stripped. Everything after (and including) the "/" should be stripped. I just want to obtain the "pure" words.

example (see attached file):

Code:
emanate/XSDVNG
emanation/M
emancipate/DSXGN
emancipation/M
emancipator/MS
Emanuele/M
Emanuel/M
emasculate/GNDSX
emasculation/M
embalmer/M
embalm/ZGRDS
embank/GLDS
embankment/MS
embarcadero
embargoes
embargo/GMD
embark/ADESG
embarkation/EMS

Please note, that not every line has a "/" in it. For example "embarcadero" has not. No action should be taken then.

Can someone give me the best command to do the job? Your help is very much appreciated.

Last edited by Don Cragun; 02-13-2014 at 09:00 PM.. Reason: Add CODE tags.
# 2  
Old 02-13-2014
Try:
Code:
sed 's|/.*||' example.txt

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 02-13-2014
Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Perl: Question about stripping tags

hey 1 more question, how do you strip tags like <p></p> from output of xml with perl? i already strip the CDATA but the annoying <p></p> still there (2 Replies)
Discussion started by: Nick1097
2 Replies

2. Shell Programming and Scripting

stripping out digits from a string with sed

i want to parse a string and only display the digits in that string... How would i accomplish this with sed command. For example. input string: " 033434343 dafasdf" output string: 03343434 Thanks (2 Replies)
Discussion started by: timmylita
2 Replies

3. Shell Programming and Scripting

stripping http and https from a url using sed

I have to write a sed script which removes http and https from a URL. So if a URL is https://www.example.com or Example Web Page, script should return me Example Web Page i tried echo $url | sed 's|^http://||g'. It doesn't work. Please help (4 Replies)
Discussion started by: vickylife
4 Replies

4. UNIX for Dummies Questions & Answers

merging 2 lines with awk and stripping first two words

Hey all i am pretty new to awk... here my problem. My input is something like this: type: NSR client; name: pegasus; save set: /, /var, /part, /part/part2, /testpartition, /foo/bar,... (9 Replies)
Discussion started by: bazzed
9 Replies

5. Shell Programming and Scripting

Stripping out extension in file name

This command gives me just the filename without any extension: evrvar =`echo filename.tar | sed 's/\.*$//'` I am trying to make a change to this command... to make it work for... filename.tar.gz to get just the filename.... currently the command gives me filename.tar by removing only gz... I... (9 Replies)
Discussion started by: devs
9 Replies

6. UNIX for Dummies Questions & Answers

[bash]Stripping lines from a list

Hello! I have a script that is (among other things) doing the following: list=/tmp/list1.txt ncftpls -u <user> -p <password> -x "-l1" server.domain.tld > $list cat $list | nl echo "Choose file: " read file cat /tmp/list1.txt | nl | grep $file | sed -e "s/$file//g" -e "s/ //g" | column -t... (8 Replies)
Discussion started by: noratx
8 Replies

7. UNIX for Dummies Questions & Answers

Question about SED for excluding lines

Hi, I'm using the SED instruction for substitution in a shell script. I'd like to improve it a bit. The instruction looks like this right now: sed '/PRAGMA/!s/package/apps.package/g' $fich_src I'm replacing the word "package" by "apps.package" for all the lines of the file $fich_src... (11 Replies)
Discussion started by: greg
11 Replies

8. Shell Programming and Scripting

Stripping out the extension of a file name

I have written a shell script and in my script i have a variable filename=myfile.txt now, i want another variable to be defined for which i have to strip out the extension fo the file name, i.e. newvariable= myfile how do i strip out the ".txt" part from my first variable. Any kind of help... (4 Replies)
Discussion started by: ramky79
4 Replies

9. Programming

Capturing a ret val of C obj file in ksh script

Hi, I have one shell script which is calling a C executable. That C executable returns a value depending upon operations inside the C code. But how to get that value in the calling shell script? The syntax of calling the C executable is like -- C_exec <argc no> <argument1> <argument2> etc... (5 Replies)
Discussion started by: k_bijitesh
5 Replies

10. UNIX for Dummies Questions & Answers

stripping last lien off a file

Hi, how can i strip the last line off my file using shell script? Thanks and Regards Vivek.S (3 Replies)
Discussion started by: vivekshankar
3 Replies
Login or Register to Ask a Question