Shell Script Unique Identifier Question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Shell Script Unique Identifier Question
# 1  
Old 07-22-2008
Shell Script Unique Identifier Question

i All

I have scripting question.
I have a file "out.txt"

which is generated by another script

the file contains the following
Code:
my_identifier8859574

logout

The number is generated in the script and I have put the my_identifier bit in front of it as a unique identifier

I now have another script which uses this file, It needs the number Only that comes after my_identifier

I havn't a breeze how to do this.
I assume i need to use awk

something like

VALUE=cat out.txt | grep my_identifier | awk .....

any suggestions?
Cheers
Graham
# 2  
Old 07-22-2008
Is my_identifier always the first line or it could be anywhere in out.txt?

If 1:

Code:
id=$(read<out.txt;printf "%s" "${REPLY#my_identifier}")


else:

Code:
id="$(fgrep my_identifier out.txt)" id="${id#my_identifier}"


Last edited by radoulov; 07-22-2008 at 07:31 AM..
# 3  
Old 07-22-2008
thank you kindly

this works perfectly
# 4  
Old 07-22-2008
Apologies for asking again

but I am now having an issue with TR

I want to make double sure that the value of id has no non-numerical characters in it.

Code:
if [ ($id | tr -d '[:digit:]') == '' ]
then
#let do the next bit
else
#email me
fi

my if syntax is not correct though

im getting the error
./test.sh[12]: Syntax error at line 12 : `(' is not expected.

any advice?
Cheers
Graham
# 5  
Old 07-22-2008
Use case:

Code:
case "$id" in
  "" | *[!0-9]* ) # email me ;;
              * ) # let do the next bit ;;
esac

# 6  
Old 07-22-2008
if [ -z "`echo $id | tr -d [0-9]`" ]
then
echo "Valid"
else
echo "Invalid"
fi
# 7  
Old 07-22-2008
thank you very much sir

Graham
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add unique identifier from file to filetype in directory

I am trying to add a unique identifier to two file extensions .bam and .vcf in a directory located at /home/cmccabe/Desktop/index/R_2016_09_21_14_01_15_user_S5-00580-9-Medexome. The identifier is in $2 of the input file. What the code below is attempting to do is strip off the last portion... (21 Replies)
Discussion started by: cmccabe
21 Replies

2. Shell Programming and Scripting

Generate 10000 unique audio file of 2MB each using shell script.

Hi, I want 10000+ unique Audio file of approx 2MB each. How can i generate numerous audio files using shell script. Any tool, command or suggestions are welcome. If i give one audio seed file then can we create numerous unique files with same seed file? Any help is highly appreciable.... (11 Replies)
Discussion started by: sushil.kumar
11 Replies

3. Shell Programming and Scripting

Identifier in shell

Dear guys I need help here with syntax, I am trying to start script command to capture all user activities every day, I want the log file of each user to be named with his login ID + date time to overcome the possibility of over writing the log file if he logoff and login again. Here is was I wrote... (5 Replies)
Discussion started by: q8devilish
5 Replies

4. Shell Programming and Scripting

Select combination unique using shell script

Hi All, bash-3.00$ gzgrep -i '\ ExecuteThread:' /******/******/******/******/stdout.log.txt.gz <Jan 7, 2012 5:54:55 PM UTC> <Error> <WebLogicServer> <BEA-000337> < ExecuteThread: '414' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "696" seconds working on the request... (4 Replies)
Discussion started by: osmanux
4 Replies

5. Shell Programming and Scripting

Shell script to count unique rows in a CSV

HI All, I have a CSV file of 30 columns separated by ,. I want to get a count of all unique rows written to a flat file. The CSV file is around 5000 rows The first column is a time stamp and I need to exclude while counting unique Thanks, Ravi (4 Replies)
Discussion started by: Nani369
4 Replies

6. Shell Programming and Scripting

Identifier In Shell script

Hi, I have a shell script and inside that shell script it calls a local .env file to set the environment for the shell script ,but the thing is that i got a error while running the script like ./myscript.sh it gives DB_NAME=dvcl021: is not an identifier that DB_Name is accessed from my .env... (6 Replies)
Discussion started by: malickhat
6 Replies

7. Shell Programming and Scripting

shell script to find and replace a line using a identifier

Hi all im having trouble starting with a shell script, i hope someone here can help me i have 2 files file1: 404905.jpg 516167 404906.jpg 516168 404917.psd 516183 404947.pdf 516250 file2: 516250 /tmp/RecyclePoster18241.pdf 516167 /tmp/ReunionCardFINAL.jpg 516168... (7 Replies)
Discussion started by: kenray
7 Replies

8. Shell Programming and Scripting

Urgent: selecting unique specific content of a file using shell script

Hi, I have a file whose content and format at places is as given below. print coloumn .... coloumn .... coloumn .... skip 1 line print coloumn ... skip 1 line I need to select the following : print coloumn .... coloumn .... coloumn... (2 Replies)
Discussion started by: jisha
2 Replies

9. Shell Programming and Scripting

Shell script to check the unique numbers in huge data

Friends, I have to write a shell script,the description is---- i Have to check the uniqueness of the numbers in a file. A file is containing 200thousand tickets and a ticket have 15 numbers in asecending order.And there is a strip that is having 6 tickets that means 90 numbers.I... (7 Replies)
Discussion started by: namishtiwari
7 Replies

10. Shell Programming and Scripting

Problem with shell script...ORA-00904:invalid identifier

Guys, Please suggest me what's wrong with this script? #!/usr/bin/sh ############################################################################## # Author : Bhagat Singh # # # Date : Nov 13,2006 #... (12 Replies)
Discussion started by: bhagat.singh-j
12 Replies
Login or Register to Ask a Question