how to remove a variable starting with dot using sed command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to remove a variable starting with dot using sed command
# 1  
Old 03-13-2012
how to remove a variable starting with dot using sed command

Hi,

I want to remove a variable starting with dot(.) in a file using sed command.

aaa
sss
.abc

s/^\.abc/d

I tried this but it didnt worked.
# 2  
Old 03-13-2012
Remove the s in sed command and try, s is for substitute but here you only delete.
Code:
sed '/^\.abc/d' inputfile 

# General solution..
sed '/^\./d' inputfile

This User Gave Thanks to michaelrozar17 For This Post:
# 3  
Old 03-13-2012
Hi,

You can better use this.
Code:
 sed 's/^\.\(.*\)//g' filename

Regards,
Indu

Last edited by Indumathy; 03-13-2012 at 04:02 AM.. Reason: For specifying filename
# 4  
Old 03-13-2012
Welcome to the forum Indu. Why is that better do you think? The ^ renders the g flag without meaning, since a match can only happen once per line. Also just deleting the first character does not delete the line.
# 5  
Old 03-13-2012
Bug ANUSURYA

Code:
sed 's/^\..*//g' dot


Last edited by Franklin52; 03-13-2012 at 04:51 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 03-13-2012
Thank u.I mistook that "." have to be deleted.

Regards,
Indu
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove prefixes before dot

Shell : Bash shell I have a text file with entries like below srv.sr_num sr_number, atvx.ATTRIB_37 Product_Name, ktx.X_ATTRIB_52 Product_Type, mkx.created sr_created_date, nbv.sr_cat_type_cd sr_type, bkrx.sr_area sr_category, .. frx.order_id, des.stats_name , fpxg.current_id_name, ...... .... (3 Replies)
Discussion started by: John K
3 Replies

2. Shell Programming and Scripting

Shellscript command to remove files starting with a certain string, and older than 3 days

Hi All, Need help in identifying a shellscript command to remove all files on a server directory, starting with a certain prefix and also older than 3 days. That means files created with that prefix, today or yesterday, shouldn't be removed. Thanks, Dev (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

3. Shell Programming and Scripting

Remove leading dot and slash on relative paths with find

When I specify a directory by name the leading ./ is not shown: $ find somedir/ somedir/a.bin somedir/target/out.binBut when I specify current dir it adds the ./ to the beginning of each result: $ find . | grep somedir ./somedir/a.bin ./somedir/target/out.binIs there any particular reason why... (2 Replies)
Discussion started by: Tribe
2 Replies

4. Shell Programming and Scripting

Using sed in a loop/to remove lines contained in variable from file

I've tried numerous commands, but I am not sure how to use sed in a loop. This is what I have: VARZ contains CARD_FILE_LIST and it also contains CARD_FILE_LIST2 so echo "$VARZ" CARD_FILE_LIST CARD_FILE_LIST2 I have a file with 60 lines in /tmp/testfile it and I want those lines deleted... (3 Replies)
Discussion started by: newbie2010
3 Replies

5. Shell Programming and Scripting

How to remove. (dot) if found in the beginning of file name while doing wget (download)?

Dear All, How to remove. (dot) if found in the beginning of file name while doing wget (download)? I am facing problem while re-sizing the image by using ImageMagick. Two dots in the file name are causing problem. ImageMagick is skipping such image with a dot . in the beginning, like ... (1 Reply)
Discussion started by: Praveen Pandit
1 Replies

6. UNIX for Dummies Questions & Answers

ls command with wild card can't return filenames starting with dot

I came across the following behaviour in Solaris 10 (x86-64bit) and RHEL 5.6 (Tikanga) -a option in ls command is supposed to list all files starting with a dot. From the man page of ls -a, --all do not ignore entries starting with . $ touch .mytestfile $ vi .mytestfile $... (2 Replies)
Discussion started by: kraljic
2 Replies

7. Shell Programming and Scripting

removing a word in a multiple file starting at the dot extension

hi I would like to ask if someone knows a command or a script on how to rename a multiple file in the directory starting at the end of the filename or at the .extension( i would like to remove the last 11 character before the extension) for example Below is the result of my command ls inside... (5 Replies)
Discussion started by: jao_madn
5 Replies

8. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

9. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

10. UNIX for Dummies Questions & Answers

variable name with dot(.)

Hi, Is it possible to declare variable with name having dot(.) in it ? something like gs.test='HELLO' Thanks in advance :) (1 Reply)
Discussion started by: gopalss
1 Replies
Login or Register to Ask a Question