deleting last characters of a word


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting deleting last characters of a word
# 1  
Old 07-15-2008
deleting last characters of a word

Hi All

is there a way to delete last n characters from a word
like say i have employee_new
i want to delete _new. and just get only employee
I want this in AIX Shell scripting

Thanks

Last edited by rajaryan4545; 07-15-2008 at 03:48 AM..
# 2  
Old 07-15-2008
Code:
 echo employee_new | awk -F_ '{print $1}'

# 3  
Old 07-15-2008
Code:
$str=employee_new
$ print ${str%_new}
employee
$

# 4  
Old 07-16-2008
Thanks a lot...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed for deleting the first word of each line?

sed /'1-2'/&^/ filename suppose there is a file containing three lines , how do we do delete the word from each line? hyter efr frf rerfer efe ewd cdcf evrfgf erfv the output has to look like frf ewd erfv (2 Replies)
Discussion started by: Rajeev Nukala
2 Replies

2. Shell Programming and Scripting

Deleting a word from a string

Hello All, I have a string like below - /LDCA20/rel/prod/libina.a I want to delete "libina.a" which is at the end.How can I do this ?? Thanks in advance Regards, Anand (10 Replies)
Discussion started by: anand.shah
10 Replies

3. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word "description" excluding weird characters like $&lmp and without html tags in the new file output.txt. Help me. Thanx in advance. I have attached the input... (4 Replies)
Discussion started by: sachit adhikari
4 Replies

4. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script?

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word description excluding weird characters like $$#$#@$#@***$# and without html tags in the new file output.txt. Help me. Thanx in advance. My final goal is to... (11 Replies)
Discussion started by: sachit adhikari
11 Replies

5. Shell Programming and Scripting

Deleting new line characters

Hi, I have a weird requirement. I am having a file with 12fields in it and the end of the line for each record is "\n" (Just \n and no carriage returns) and the field delimiter is "|". Problem is I can have new line characters in any field in the data and these new line characters can even come... (11 Replies)
Discussion started by: ngkumar
11 Replies

6. Shell Programming and Scripting

sed - deleting each line up to a word

Hi there, I'd like to delete the beginning of a line up until it finds a certain word or character string: in this case, I'd like to delete each line up to the word "mounting". Thanks ;) Susan (12 Replies)
Discussion started by: kitykity
12 Replies

7. Shell Programming and Scripting

deleting lines above and below a word!

i jst want to delete a host entry from httpd.conf for eg: i have entries such as: <VirtualHost 192.168.1.157:80> DocumentRoot /home/karthik ServerName kar </VirtualHost> <VirtualHost 192.168.1.157:80> DocumentRoot /home/karthik1 ServerName www </VirtualHost> <VirtualHost... (4 Replies)
Discussion started by: jacky29
4 Replies

8. Shell Programming and Scripting

deleting rows that have certain characters

Hi, I want to delete rows whenever column one has the letters 'rpa'. The file is tab seperated. e.g. years 1 bears 1 cats 2 rpat 3 rpa99 4 rpa011 5 then removing 'rpa' containing rows based on the first column years 1 bears 1 cats 2 thanks (7 Replies)
Discussion started by: phil_heath
7 Replies

9. Shell Programming and Scripting

Help need in Deleting Characters

Hi, I have a log file whose size is number of characters in the file with multiple lines. Example: SQL*Loader: Release 10.2.0.4.0 - Production on Sat Sep 12 07:55:29 2009 Copyright (c) 1982, 2007, Oracle. All rights reserved. Control File: ../adm/ctl/institution.ctl Character Set... (4 Replies)
Discussion started by: rajeshorpu
4 Replies

10. UNIX for Dummies Questions & Answers

Need help with deleting certain characters on a line

I have a file that looks like this: It is a huge file and basically I want to delete everything at the > line except for the number after “C”. >c1154... (2 Replies)
Discussion started by: kylle345
2 Replies
Login or Register to Ask a Question