Character selection script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Character selection script
# 1  
Old 11-20-2003
Character selection script

Hi all

I have this bit of code:
Code:
mv horders.unx horders.txt

FILE=horders.txt
awk '
	BEGIN{FS=","}
	{
		if ($1=="HEAD")
		{
			REF=$5;
			print $0;
		}
		if ($1=="LINE")
		{
			print $0 "," REF;
		}
		if ($1=="TEXT")
		{
			print $0 "," REF;
		}
	}' < $FILE > $FILE.new

Field 5 ($5) will contain an alphanumeric sequence of a varying amount of characters. I need to be able to grab the last 10 characters of the sequence and print them to the 'REF' variable.

Can anyone help with this please? Thanks
# 2  
Old 11-20-2003
How about replacing

REF=$5; with

REF=substr($5,length($5)-9); ?
# 3  
Old 11-20-2003
MySQL

You're the man oombera! Smilie Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Selection from array

Hi, I need some help taking a selection from a command and adding part of the output to an array. I'd like to read the items into the array, have the user chose an option from the array and put the item from column 1 into a variable. The command is: awless -l list routetables --columns... (7 Replies)
Discussion started by: bignellrp
7 Replies

2. Shell Programming and Scripting

How to automate user selection options in shell script?

Hi There, I am trying to write a script which has to pick the prompted options by itself(i mean option to choose will be passed) here is real scenario i am trying to do. i have an executable(diagnos) which gets called in shell script, when the executable (diagnos) runs i get following as... (8 Replies)
Discussion started by: sairam_9191
8 Replies

3. Shell Programming and Scripting

A selection menu in a shell script

I'm writing a shell script and have a problem with selection when I issue the command, is there a way to automatically choose a selection number one after a selection menue appear Command 1-choice 2- choice 3-choice Thanks Sara (3 Replies)
Discussion started by: Sara_84
3 Replies

4. Shell Programming and Scripting

If Selection statement

ok im kinda stuck i have a bash script with 4 options 1. Create Script 2. Show Script 3 . Delete script 4. Exithow would i use an if statement for this? im not sure what test command i would use. I know it would be like this (below) to display the script if then cat script1or for the... (10 Replies)
Discussion started by: gangsta
10 Replies

5. Shell Programming and Scripting

Date selection

Hi All, i have log file sample data is 2010/10/09|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/08|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/07|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/05|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/03|04:00:00.392|15Minute|BW=0|192.168.0.1... (2 Replies)
Discussion started by: posner
2 Replies

6. Shell Programming and Scripting

Data selection

Hi, I have a file containing details of different departments . Infomration of departments is in various tags file is as below I want to create a new file from the above file which should contain only two fields belonging to one department format There are multiple files... (1 Reply)
Discussion started by: test_user
1 Replies

7. Post Here to Contact Site Administrators and Moderators

Opt out selection

Maybe I'm missing something but when I go to CP->Options, I see the box for selecting which forum to opt out of but no way to set it. (5 Replies)
Discussion started by: drhowarddrfine
5 Replies

8. UNIX for Advanced & Expert Users

tray selection

Hello All, Could anyone help me how to selecting the trays in unix . Thanks, Amit kul (3 Replies)
Discussion started by: amit kul
3 Replies

9. Shell Programming and Scripting

Array and Selection

I have a question: Y X Tabel a is a array multidimensional --> a(1024,20) I load in to array a Text from 6000 row where: in a(1,1) is present the row 1 of original text, in a(1024,1) is present then row 1024 of original test and in... (4 Replies)
Discussion started by: ZINGARO
4 Replies

10. SCO

On-screen character size selection

Late one evening I stumbled into a part of SCO 5.06 wherein I was asked for my choice of large or small characters. Without a thought, I picked "large". This was a mistake, since many operating system directories now show only part of their contents. The rest is off-screen. I can't seem to be... (0 Replies)
Discussion started by: jddxxx
0 Replies
Login or Register to Ask a Question