Sponsored Content
Top Forums Shell Programming and Scripting Bash string variable manipulation Post 302358972 by ASGR on Monday 5th of October 2009 10:53:52 AM
Old 10-05-2009
using string manipulation

Hi,

Indeed it is easy (after spending hours and hours and hours ...)
You can use string manipulation to achieve your objective via:

Code:
new_dir=${the_dir%/bin*}

Essentially, it matches /bin and anything after that hence the * and returns the left of the string that was not matched.

A.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash assign string to variable

Hi ,I am trying to assign string to variable ,but it doesn't work Also could you show me different ways to use grep,(I am trying to get the first,second and first column form file,and I am counting the chars) let name=`grep "$id" product | cut -c6-20` (25 Replies)
Discussion started by: lio123
25 Replies

2. UNIX for Advanced & Expert Users

string manipulation in bash shell

Hi All, I am using a bash shell and want to the following thing. A process sends the following string to my script BACKUP_FAIL_REASON="Failed - Application Dump CDMACA-0:grep: /opt/nortel/ca/data/1245184/sd00/image1/S110907070708HIS... (4 Replies)
Discussion started by: Pkumar Sachin
4 Replies

3. Shell Programming and Scripting

bash string manipulation

Hello guys, here is my problem: I got a shell script which is called by an external piece of software, the external software is not under my control. The software passes data as an argument to my script like ./bla.sh 'service;1234567890;ok;hostname;some text here' I need to pass the... (3 Replies)
Discussion started by: snoogie
3 Replies

4. Shell Programming and Scripting

Bash string manipulation

In my script I'm retrieving a parameter through an API call. I need to trim some things out of the result so I can use it as a parameter to pass to another process. I've got it working but it's pretty kludgy and I'm hoping someone can help me with a better way. This is the code that retrieves... (2 Replies)
Discussion started by: withanh
2 Replies

5. UNIX for Dummies Questions & Answers

bash variable string declaration

Hello, Why is this not working in a script? files="test.fsa" echo $files for file in $files do if then echo "$file does not exist." fi run a command done I get an error saying (3 Replies)
Discussion started by: verse123
3 Replies

6. Shell Programming and Scripting

Bash string variable outputting incorrectly

Hello All, I am learning BASH scripting and I would appreciate any help with a small problem I am having... I am writing a script that builds a simple hosts file for DNS reasons related to a piece of software called netdb by parsing another application's config files for IP's and their... (4 Replies)
Discussion started by: Wesley545
4 Replies

7. Shell Programming and Scripting

bash: using a string variable in grep

Hi, I've been stuck for several days on this. Using grep on a command line, I can use quotes, eg... grep 'pattern of several words' filename I want to do this in my bash script. In my script I have captured the several command line arguments (eg arg1 arg2) into a variable: variable=$@ I... (2 Replies)
Discussion started by: adrian777uk
2 Replies

8. Shell Programming and Scripting

Passing string as variable(s) in bash

I'm trying to write a basic bash script that takes input you give (what directory, if any, what name, if any ....) and passes the information to find. I'm trying to just create a string with all variables and then pass it to find. So far I have this extremely simple: #!/bin/bash -f ... (2 Replies)
Discussion started by: Starting_Leaf
2 Replies

9. Shell Programming and Scripting

Variable string manipulation

Hi, I have a variable with grep output like this: WORDS=$(grep -r -c -i -E "palindrom" /"$DIRECTORY"/) so "echo "$WORDS"" could be: //directory/file1.txt:0 //directory/file2.txt:0 //directory/file3.txt:3 //directory/file4.txt:1 //directory/file5.txt:0 I need to "sed" my variable... (3 Replies)
Discussion started by: Hornys
3 Replies

10. Shell Programming and Scripting

ksh String Manipulation - removing variables from within a variable

Hi. I'd like to remove all values in a string variable that also exist in a second variable. What is the appropriate approach to take here? I can use a 'For' loop and check each element and then populate a new string. But is there a cleaner, simpler way? E.g. I have the following 2 variables ... (19 Replies)
Discussion started by: user052009
19 Replies
Courier::Filter::Module::FakeDate(3pm)			User Contributed Perl Documentation		    Courier::Filter::Module::FakeDate(3pm)

NAME
Courier::Filter::Module::FakeDate - Fake "Date:" message header filter module for the Courier::Filter framework SYNOPSIS
use Courier::Filter::Module::FakeDate; my $module = Courier::Filter::Module::Header->new( forward_tolerance => { # years, months, weeks, days, hours, minutes, seconds hours => 2 }, backward_tolerance => { # years, months, weeks, days, hours, minutes, seconds days => 5 }, ignore_unparseable => 0, logger => $logger, inverse => 0, trusting => 0, testing => 0, debugging => 0 ); my $filter = Courier::Filter->new( ... modules => [ $module ], ... ); DESCRIPTION
This class is a filter module class for use with Courier::Filter. It matches a message if it has a "Date" header field that lies too far in the future or the past, relative to the local system's time. If the message has a "Resent-Date" header field (see RFC 2822, 3.6.6), that one is examined instead, because the message could simply be an old one that has recently been re-sent, which is perfectly legitimate behavior. In the case of a match, the response tells the sender that their "Date" header is implausible and that they should check their clock. Note: Times in different time zones are compared correctly. Note: When using this filter module, it is essential that the local system's own clock is set correctly, or there will be an increased risk of legitimate messages getting rejected. Constructor The following constructor is provided: new(%options): returns Courier::Filter::Module::FakeDate Creates a new FakeDate filter module. %options is a list of key/value pairs representing any of the following options: forward_tolerance backward_tolerance The maximum durations by which a message's "Date" or "Resent-Date" header may diverge into the future and the past, respectively, from the local system's time. Each duration must be specified as a hash-ref containing one or more time units and their respective quantity/ies, just as specified by DateTime::Duration. "forward_tolerance" defaults to 2 hours. "backward_tolerance" defaults to 5 days to account for transmission delays. For example: forward_tolerance => { hours => 4 }, backward_tolerance => { days => 1, hours => 12 } ignore_unparseable A boolean value controlling whether messages whose "Date" or "Resent-Date" header does not loosely conform to RFCs 822 or 2822 should be ignored (true) or matched (false). Defaults to false. All options of the Courier::Filter::Module constructor are also supported. Please see "new" in Courier::Filter::Module for their descriptions. Instance methods See "Instance methods" in Courier::Filter::Module for a description of the provided instance methods. SEE ALSO
Courier::Filter::Module, Courier::Filter::Overview. For AVAILABILITY, SUPPORT, and LICENSE information, see Courier::Filter::Overview. AUTHOR
Julian Mehnle <julian@mehnle.net> perl v5.14.2 2011-12-27 Courier::Filter::Module::FakeDate(3pm)
All times are GMT -4. The time now is 01:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy