Sponsored Content
Top Forums Shell Programming and Scripting bash : Adding numeric order to blank field Post 302674205 by maverick_here on Thursday 19th of July 2012 06:52:56 AM
Old 07-19-2012
bash : Adding numeric order to blank field

Hi All,

I have a file menu_opts is as follows

Code:
[root@##### ~]# cat menu_opts
Please select the options
qqqq_usb         STD RETAIL Progs    (Prime time cue advertisements)
qqqq_onc         STD Dealer Progs    (Prime time cue advertisements)
qqqq_zt_usb      STD RETAIL Progs    (Long Format cue advertisements)
qqqq_zt_onc      STD Dealer Progs    (Long Format cue advertisements)
qqqq_us_zt_onc   SA Dealer Progs          (Long Format cue advertisements)
qqqq_dart_usb    WholeSAle RETAIL Progs (Prime time cue advertisements)
qqqq_dart_onc    WholeSAle Dealer Progs (Prime time cue advertisements)
qqqq_dart_zt_usb WholeSAle RETAIL Progs (Long Format cue advertisements)
qqqq_dart_zt_onc WholeSAle Dealer Progs (Long Format cue advertisements)

Im trying to write a shell script, which would display a menu and look as follows

Code:
Please select the options

1] STD RETAIL Progs    (Prime time cue advertisements)
2] STD Dealer Progs    (Prime time cue advertisements)
3] STD RETAIL Progs    (Long Format cue advertisements)
4] STD Dealer Progs    (Long Format cue advertisements)
5] SA Dealer Progs          (Long Format cue advertisements)
6] WholeSAle RETAIL Progs (Prime time cue advertisements)
7] WholeSAle Dealer Progs (Prime time cue advertisements)
8] WholeSAle RETAIL Progs (Long Format cue advertisements)
9] WholeSAle Dealer Progs (Long Format cue advertisements)

Enter a choice or Q to quit

Im facing challenge as I unable to get this display so far following is the progress i made

Code:
[root@##### ~]# cat menu_opts  |head -n 1;echo -e "\n";cat menu_opts |tail -n +2|awk '{gsub(/^ *[^ ]* */," ")}1'



Please select the options


 STD RETAIL Progs    (Prime time cue advertisements)
 STD Dealer Progs    (Prime time cue advertisements)
 STD RETAIL Progs    (Long Format cue advertisements)
 STD Dealer Progs    (Long Format cue advertisements)
 SA Dealer Progs          (Long Format cue advertisements)
 WholeSAle RETAIL Progs (Prime time cue advertisements)
 WholeSAle Dealer Progs (Prime time cue advertisements)
 WholeSAle RETAIL Progs (Long Format cue advertisements)
 WholeSAle Dealer Progs (Long Format cue advertisements)

Please help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to numeric sort on field time

i want to sort time field given by who command as a whole i have tried like this who|sort -n +4 -5 (1 Reply)
Discussion started by: rahulspatil_111
1 Replies

2. Linux

Using sort command to get numeric ascending order

HI everyone, I am trying to use the unix sort command to get a list of numbers sorted in ascending order but having trouble in getting it to work. An example of this issue would be when i am trying to sort the following three number each on a different line "1" , "2" and "116" the sort command... (3 Replies)
Discussion started by: wali4813
3 Replies

3. Shell Programming and Scripting

sed/awk-adding numeric to a column

I have a txt file as follows Code: Oct 1 file1 4144 Oct 1 file23 5170 Oct 2 file5 3434 Oct 21 file56 2343 I need to add a new column by marking the right log file from current directory. For example populate like this. Please not in the second columt for "1" it has... (2 Replies)
Discussion started by: gubbu
2 Replies

4. Shell Programming and Scripting

adding field values if field matches

hi i have file as below , i want to add duplicate records like bell_bb to one record with valuve as 15 ( addition of both ) any oneline awk script to achive this ? header 0 CAMPAIGN_NAME 1 Bell_BB 14 Bell_MONTHLY 803 SOLO_UNBEATABLE 644 Bell_BB 1 Bell_MONTHLY 25 SOLO_UNBEATABLE... (4 Replies)
Discussion started by: raghavendra.cse
4 Replies

5. Shell Programming and Scripting

Perl script to sort data on second numeric field

Hi, I'm a learner of PERL programming. I've a input file with the below data: SWAT_5, 1703, 2010-09-21 SWAT_6, 2345, 2010-09-21 SWAT_7, 1792, 2010-09-21 SWAT_8, 1662, 2010-09-21 SWAT_9, 1888, 2010-09-21 VXHARP_1, 171, 2010-09-21 I need to sort this data based on the second... (6 Replies)
Discussion started by: ganapati
6 Replies

6. Shell Programming and Scripting

Adding total of first field for each number in the second field

Dears, I need a script or command which can find the unique number from the second filed and against that number it adds the total of first field . 17215630 , 0 907043 ,1 201050 ,10 394149 ,4 1964 ,9 17215630, 0 907043 ,1 201050, 10 394149 ,4 1964 ,9 1234234, 55 23 ,100 33 ,67 ... (2 Replies)
Discussion started by: shary
2 Replies

7. Shell Programming and Scripting

Sort help on non numeric field

Hi, I am unable to sort data on the first field $cat t Jim,212121,Seattle Bill,404404,Seattle Steve,246810,Nevada Scott,212277,LosAngeles Jim,212121,Ohio sort -t"," -k1,2 t Bill,404404,Seattle Jim,212121,Ohio Jim,212121,Seattle Scott,212277,LosAngeles Steve,246810,Nevada (7 Replies)
Discussion started by: Shivdatta
7 Replies

8. Shell Programming and Scripting

Adding an additional blank field to a file

Hi, I have the following file, I'd like to add an additional blank field to this file This is a tab delimited file, I have tried the same thing on excel, but looking for a unix solution. Here is my input: Country Postal Admin4 StreetBaseName StreetType HUN 2243 Kóka Dózsa György ... (3 Replies)
Discussion started by: ramky79
3 Replies

9. Shell Programming and Scripting

Sort numeric order

Hi I am using this cat substitutionFeats.txt | gawk '{$0=gensub(/\t/,"blabla",1);print}' | gawk '{print length, $0}' | sort -n | sort -r and the "sort -n" command doesn't work as expected: it leads to a wrong ordering: 64 Adjustable cuffs 64 Abrasion- 64 Abrasion pas 647 Sanitized 647... (4 Replies)
Discussion started by: louisJ
4 Replies

10. Shell Programming and Scripting

[Solved] sort on numeric part of field

I have ran into a heavy case of PEBCAK*) and could need some advice on what i do wrong: OS is Linux (kernel 2.6.35), sort --version reports "8.5" from 2010, shell is ksh. Originally i had a file with with the following structure: hdisk1 yyy hdisk2 yyy hdisk3 yyy hdisk4 yyy hdisk5 yyy... (2 Replies)
Discussion started by: bakunin
2 Replies
CUE(4)							   BSD Kernel Interfaces Manual 						    CUE(4)

NAME
cue -- CATC USB-EL1210A USB Ethernet driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device uhci device ohci device usb device cue Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_cue_load="YES" DESCRIPTION
The cue driver provides support for USB Ethernet adapters based on the Computer Access Technology Corporation's USB-EL1210A chipset. The USB-EL1210A supports a 512-bit multicast hash filter, single perfect filter entry for the station address and promiscuous mode. Packets are received and transmitted over separate USB bulk transfer endpoints. The CATC chipset supports only 10Mbps half-duplex mode, hence there are no ifmedia(4) modes to select. For more information on configuring this device, see ifconfig(8). HARDWARE
The cue driver supports CATC USB-EL1210A based USB Ethernet adapters including: o Belkin F5U011/F5U111 o CATC Netmate o CATC Netmate II o SmartBridges SmartLink DIAGNOSTICS
cue%d: watchdog timeout A packet was queued for transmission and a transmit command was issued, however the device failed to acknowledge the transmission before a timeout expired. cue%d: no memory for rx list The driver failed to allocate an mbuf for the receiver ring. SEE ALSO
arp(4), netintro(4), ng_ether(4), ifconfig(8) HISTORY
The cue device driver first appeared in FreeBSD 4.0. AUTHORS
The cue driver was written by Bill Paul <wpaul@ee.columbia.edu>. BSD
July 16, 2005 BSD
All times are GMT -4. The time now is 11:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy