Sponsored Content
Top Forums Shell Programming and Scripting Setting basename and dirname variable to simply script. Post 302135785 by porter on Wednesday 12th of September 2007 01:36:38 PM
Old 09-12-2007
Quote:
Originally Posted by liketheshell
cat "/apps/opt/tmp/baaisMFile" | mailx -s "Alert: $(hostname) Baais File not Found" $alertUser
1. Did you intend ${hostname} ?

2. Personally I have all variables upper-case to make them obvious.

3. Try..

Code:
DIRNAME=`dirname $SOMEFILE`
BASENAME=`basename $SOMEFILE`
echo $BASENAME is in $DIRNAME

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

setting a global variable in script

Hi All, I know to set global variable i can use export .. But take the situation like below .. I want to set a variable in one script and access that in second script i have done like this .. It is not working one.sh #!/usr/bin/ksh echo $RISSHI export RISSHI=1 two.sh... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Shell Programming and Scripting

dirname, save cut portion to variable, clean up

Hi guys, last cry for help for today. I appreciate the help so far. ok so I have a program that dumps a path into my script as a variable ($1) This path is an example /home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3 So in order to search thetvdb.com for a show, I need to extract... (6 Replies)
Discussion started by: tret
6 Replies

3. Programming

basename and dirname changes the value of argument???

Hi I faced with some interesting behavior of basename and dirname functions from libgen.h: they changes the value of argument! Here is the declaration: char *basename(char *); char *dirname(char *);It makes some tiresome to use them... I am new to C and maybe I do something wrong, but to... (4 Replies)
Discussion started by: Sapfeer
4 Replies

4. Shell Programming and Scripting

Setting environment variable using shell script

Hi All, I'm trying to write an menu driven program to automate some functions which involve loging to multiple hosts. The hosts can differ for every use, so I thought I would use an config file to get the hostnames. Now I need to set those values in the config file to environment variable to... (6 Replies)
Discussion started by: arun_maffy
6 Replies

5. Shell Programming and Scripting

Setting a variable in a while loop (.ksh script)

Hello Everyone, I'm still trying to grasp many concepts in .ksh scripting, one of them being variables inside loops. My problem is the following: * I'm trying to set a variable inside a while read loop to reuse it outside of said loop. My lines are the following :... (13 Replies)
Discussion started by: jimmy75_13
13 Replies

6. Shell Programming and Scripting

setting a shell script variable in awk

The following is part of a larger shell script grep -v "Col1" my_test.log | grep -v "-" | awk '$5 == "Y" {print $1}' instead of printing, can I set set $1 to a variable that the rest of the shell script can read? if $5 == Y, I want to call another shell script and pass $1 as a... (2 Replies)
Discussion started by: guessingo
2 Replies

7. UNIX for Advanced & Expert Users

Setting a permanent global variable in unix accessible from any script

Is there anyway in which i can set a permanent global variable in unix, which when initialised with a value and modified during any shell script, would retain its value even if i logout and login I dont know whether i am being able to express my need clearly but basically what i want is a... (3 Replies)
Discussion started by: arindamlive
3 Replies

8. Shell Programming and Scripting

Setting a TZ variable in a script

Hello all, I know this must be simple .... but i can't grasp what could be the issue. I'm trying to setup the timezone variable (to the unix command date) according to what i find in a value that i got from parsing the config file. The end result would be setting the log file with this new... (4 Replies)
Discussion started by: maverick72
4 Replies

9. Programming

Basename for directory variable

hi all, trying to get this to work but im struggling abit and wondered if you can help me out basically i have created a variable base='basename $dir' echo "please specify full path to directory you want to be made into a tar" read -e dir tar -cf... (7 Replies)
Discussion started by: robertkwild
7 Replies

10. Shell Programming and Scripting

Assigning basename result to another variable

This is a two part request for an assistance. I am not sure how retrieve value from basename command - line 270 -so in can be output as variable CLI_COMMAND - line 250 in whiptail input box. As coded I can input from keyboard ( stdin?) into input box using redirection. I can... (2 Replies)
Discussion started by: annacreek
2 Replies
CRC32(3)						User Contributed Perl Documentation						  CRC32(3)

NAME
String::CRC32 - Perl interface for cyclic redundency check generation SYNOPSIS
use String::CRC32; $crc = crc32("some string"); $crc = crc32("some string", initvalue); $somestring = "some string"; $crc = crc32($somestring); open(SOMEFILE, "location/of/some.file"); $crc = crc32(*SOMEFILE); close(SOMEFILE); DESCRIPTION
The CRC32 module calculates CRC sums of 32 bit lenghts. It generates the same CRC values as ZMODEM, PKZIP, PICCHECK and many others. Despite its name, this module is able to compute the checksum of files as well as strings. EXAMPLES
$crc = crc32("some string"); results in the same as $crc = crc32(" string", crc32("some")); This is useful for subsequent CRC checking of substrings. You may even check files: open(SOMEFILE, "location/of/some.file"); $crc = crc32(*SOMEFILE); close(SOMEFILE); A init value may also been supplied in the above example. AUTHOR
Soenke J. Peters <peters__perl@opcenter.de> Please be so kind as to report any bugs/suggestions to the above address. COPYRIGHT
CRC algorithm code taken from CRC-32 by Craig Bruce. The module stuff is inspired by a similar perl module called String::CRC by David Sharnoff & Matthew Dillon. Horst Fickenscher told me that it could be useful to supply an init value to the crc checking function and so I included this possibility. The author of this package disclaims all copyrights and releases it into the public domain. perl v5.16.3 2005-04-04 CRC32(3)
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy