Sponsored Content
Top Forums Shell Programming and Scripting Cut a script name to create a blank file Post 302906265 by rbatte1 on Wednesday 18th of June 2014 11:49:36 AM
Old 06-18-2014
These are much easier to do with variable substitution. It sounds hard to get started, but it's easier when you get the hang of it.

Is SCRIPT_NAME a value you will read as input or do you want it to be the name of the script you are already running? The current running script will be known as $0, parm 1 is $1, parm 2 is $2 etc.

If you are using this, then you can slice the values up however you like, such as:-
Code:
SCRIPT_NAME=$0
echo $SCRIPT_NAME

SCRIPT_NAME="${0##*/}"               # Trim off everything up to and including the last /, i.e. the path.
echo $SCRIPT_NAME

SCRIPT_NAME="${SCRIPT_NAME%.sh}"     # Trim off a trailing .sh from what you've already got
echo $SCRIPT_NAME

PARM1=$1
echo $PARM1

You might be wanting to read from an input file as you seem to suggest with your done <"ListFile.txt" so you could also do this:-
Code:
while read scr par1 par2
do
   trimmed="${scr%.sh}"
   echo "I'm running $trimmed with parm1=$par1 and parm2=$par2"
   echo "My completion flag will be $trimmed.$par1.$par2.finished"
done < listfile.txt

Does that help?

Be aware that if you have three parameters, then this while read will put the 2nd & 3rd parameter into $par2


Robin

Last edited by rbatte1; 06-18-2014 at 12:51 PM.. Reason: Added parm3 warning
This User Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Blank Space is not appending in each row of CSV File - Shell Script

I am calling SQL script in my UNIX Shell script and trying to create the CSV file and my last column value of each row is 23 blank spaces. In my SQL script,the last column is like below. RPAD(' ',23,' ') -- Padding 23 blank Spaces The CSV file is generated but the sapce(23 spaces) is... (2 Replies)
Discussion started by: praka
2 Replies

2. Shell Programming and Scripting

How to delete the blank file while running a script.

Hi All, When i am runing a script from home directory the output is fine, but whenever i am running a script from any of the directory the output is fine while a "Blank file" is created named as "1" in the particular directory. Will you please suggest any options to fix this problem. It... (1 Reply)
Discussion started by: r_jha17
1 Replies

3. Red Hat

Script to remove a blank in a file on Redhat

Hi, I'm running 2.6.9-55.ELsmp. I'm looking for a script to remove a blank line on the first line of a file. The script must also test if the file is 0k, if yes then do nothing, but if the file is > 0k then check if the first line is not blank, if yes then remove the line then save it. ... (4 Replies)
Discussion started by: lamoul
4 Replies

4. Shell Programming and Scripting

Cut last blank space

Hello, I am using this to get only directories : ls -l | grep '^d'and here is the result : drwx------ 13 so_nic sonic 13 Nov 4 13:03 GLARY drwx------ 3 so_nic sonic 3 May 6 2010 PSY2R drwx------ 15 so_nic sonic 15 Oct 14 08:47 PSYR1 But I only need to keep this... (7 Replies)
Discussion started by: Aswex
7 Replies

5. Shell Programming and Scripting

How to cut data from file and create another file.

I have file which has more than 1000 lines. PFB file info Line 1. <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"... (8 Replies)
Discussion started by: humaemo
8 Replies

6. Shell Programming and Scripting

Remove Space and blank line from file in UNIX shell script

I have below file. I want to remove space at begining of every line and then after also remove blank line from file. I use below code for each operation. sed -e 's/^*//' < check.txt > check1.txt sed '/^\s*$/d' < check1.txt > check2.txt above code not remove all the space... (12 Replies)
Discussion started by: Mohin Jain
12 Replies

7. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies

8. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : ®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

9. Shell Programming and Scripting

Script to find blank records in a file except for few columns

I have a file with the following format: X|High|2|GIC|DM||XHM|||6 Months X|Moderate|2|GIC|DM||XHM|||6 Months X|High|2|GCM|DM||XSF|||6 Months X|Med|2|GCM|DM||XSF|||6 Here there are ten columns but I need to print rows having blank records in any of the rows (except for 6th,8th and 9th... (10 Replies)
Discussion started by: chatwithsaurav
10 Replies

10. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies
uudemon(4)						     Kernel Interfaces Manual							uudemon(4)

NAME
uudemon.admin, uudemon.cleanu, uudemon.hour, uudemon.poll - Administrative shell scripts for polling remote systems, cleaning up spool directories, reporting status to the system administrator, and routine invocations of the uuxqt and uusched daemons SYNOPSIS
These shell scripts reside in the following directory: /usr/lib/uucp DESCRIPTION
All the scripts can be run from the command line or can be run automatically by the cron daemon. To automatically run the scripts, remove the comment character (#) from the beginning of the relevant line in the /var/spool/cron/crontabs/uucp file. This script reports status to the system administrator. It issues the uustat command to find out the status of uucp jobs. It mails the results to the uucp login ID. The script may be modified to send mail to any login ID such as the uucp administrative login ID (uucpa) or root. This script cleans up the /var/spool/uucp and /var/spool/uucppublic directories by running the uucleanup command. The uucleanup com- mand is run with the following parameters: -C7, -D7, X2, -o2, -W1. This script runs the uusched and uuxqt daemons in the background. This script polls the systems listed in the /usr/lib/uucp/Poll file. The uudemon.poll script should be scheduled before the uudemon.hour script. This allows uudemon.poll to create any command files before cron runs the uudemon.hour script. FILES
Contains the uudemon.admin, uudemon.cleanu, uudemon.hour and uudemon.poll files. Contains the uucp file. RELATED INFORMATION
Commands: cron(8), uucleanup(8), uusched(8), uuxqt(1) Files: /usr/lib/uucp delim off uudemon(4)
All times are GMT -4. The time now is 08:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy