The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Command to parse a word character by character girish.raos Shell Programming and Scripting 6 09-03-2009 04:18 AM
How to delete all character before certain word phandy UNIX for Dummies Questions & Answers 9 01-31-2009 10:14 PM
Delete between 10th character and 20th character nuno_fbo UNIX for Dummies Questions & Answers 2 12-17-2008 03:08 PM
to search for a particular character in a word ssuresh1999 UNIX for Dummies Questions & Answers 6 10-07-2008 03:49 PM
Grep for X character on a word jjoves UNIX for Dummies Questions & Answers 5 08-06-2004 06:14 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-30-2009
newpromo newpromo is online now
Registered User
  
 

Join Date: Sep 2009
Posts: 11
Delete character from a word

Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp :

I want to replace "20091001" by "091001"

or "replace" by "place"

Thx,
  #2 (permalink)  
Old 09-30-2009
rdcwayx rdcwayx is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 264
By GNU date


Code:
date -d 20091001 "+%y%m%d"

091001

Or by Awk:


Code:
echo "20091001" | awk '{print substr($1,length($1)-5)}'


Last edited by rdcwayx; 09-30-2009 at 10:22 PM..
  #3 (permalink)  
Old 09-30-2009
newpromo newpromo is online now
Registered User
  
 

Join Date: Sep 2009
Posts: 11
Thank you,

In fact i'm trying to get time 15 min ago, so i'm using this command :

feefth=`perl -e '($s,$m,$h,$J,$M,$A) = localtime(time - 15*60) and printf("%d%02d%02d%02d%02d\n",$A+1900,$M+1,$J,$h,$m)'`


But the result is : 20091001.0155

I need it to be only : 0910010155
  #4 (permalink)  
Old 10-01-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,436
Quote:
Originally Posted by newpromo View Post
In fact i'm trying to get time 15 min ago
I just ask myself what is the relationship between your thread title and your problem
  #5 (permalink)  
Old 10-01-2009
newpromo newpromo is online now
Registered User
  
 

Join Date: Sep 2009
Posts: 11
In fact i tried to make my request more general to make it easy for you to help me, i give two exp : "20091001" by "091001" and "replace" by "place"

deleting the caracteres "20" from the word "20091001" to be "091001"

and deleting the caracteres "re" from the word "replace" tp be "place".

I found also an other solution by leaving "20" static in my script because it's not going to change very soon !!!

Anyway, thanks for your help and i'm very glad to have a quick answer to my first post
  #6 (permalink)  
Old 10-01-2009
ripat ripat is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2006
Location: Belgium
Posts: 438
Quote:
Originally Posted by newpromo View Post
I found also an other solution by leaving "20" static in my script because it's not going to change very soon !!!
Indeed. And even Stevie Ballmer will be using *nix by then!
  #7 (permalink)  
Old 1 Day Ago
tukuyomi tukuyomi is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 42
Another way:
Code:
~$ d=$(date +%Y%m%d); echo ${d}; echo ${d#??}
20091201
091201

d='replace'; echo ${d}; echo ${d#??}
replace
place

Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0