![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help NEEDED urgently on exceutable file | jagan_kalluri | UNIX for Dummies Questions & Answers | 5 | 05-29-2008 03:06 PM |
| Need help urgently | user_prady | Shell Programming and Scripting | 3 | 09-03-2007 09:51 PM |
| Major Help Urgently Needed!!!! | billett05 | UNIX for Dummies Questions & Answers | 3 | 07-20-2005 02:55 PM |
| Need Information Urgently. | sumit_krishan | UNIX for Dummies Questions & Answers | 3 | 06-08-2005 06:13 AM |
| Shell Script needed urgently | vas_dba | Shell Programming and Scripting | 2 | 03-11-2005 09:00 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
hi all
i need help I am confused and stucked. Actually i am new in this scripting stuff. I want to give complete txt file as a input to a variable and then sort the data in the file according to the alpha numeric characters, as my text file contains ! and !! and !!! indicating Minor, Major and Critical repectively. Each alpha numeric represent new entry. I am trying to do but all in vain, help needed plz,codes which i am trying are as follows, [code]: #!/bin/bash alarmfile= `cat ~/alkatel.txt` [\code] i tried so many times but whenever i try to take file as input by code above but i got the output >> : command not found its a long file ,im sending a part of this text file that i want to take as input example of file >> ALAIL; CMD ALAIL 06095 08-01-30 11-58-23 INP ALAIL 06095 08-01-30 11-58-23 OPTEX= RES ALAIL 06095 08-01-30 11-58-24 CEN=1/08-01-30/11 H 58 MN 19/STORED ALARMS LIST PROCESSING TPFFIR ACC ! *A0628/540 /07-12-17/15 H 58/N=7598/TYP=ICT/CAT=SI/EVENT=MAL /NCEN=MULCT /AM =SMTA1/AGEO=S1-TR01-B03-A085-R000 /TEXAL=AIS/COMPL.INF: /AF=URMA1 / ICTRQ AGCA=S1-TR01-B03-A112-R065 /AMET=01-07-02 /AFLR=222-09/CRC=NACT !!! *A0628/303 /07-12-17/15 H 46/N=7501/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 4/AGEO=BUDLASAN-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=3 if i removed these >> operators from the start of file i again got the same output ALAIL ; :command not found even this file doesnt have executeable permission but still i am getting this message i am so confused as i am still at my first step since 3 days please help me, why it doesnt take the whole file as text input rather the first word and ignorin the rest of file as i told befor ! & !!! showing minor & critical alarms.its a log file of alkatel switch & i have to extract !!! , !! , ! with relevant date & time e.g !!! */07-12-17/15 H 46/ event i.e. EVENT=MAL & texal i.e. /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF i collected stuff about reg exp from this site to take yhe substring but couldnt find a way still let me make it very clear that i need this script in bash onlynot perl and any other language i tried another script to extract entry components from the file as Code:
:
#!/bin/bash
var=~/alkatel.txt
while read line $var
do
{
echo $line
}done
but the out put became the infinite loop of the first line as >> ALAIL; :command not found can any one do it waiting for reply soon ![]() |
|
||||
|
file starts as follows
>> ALAIL; CMD ALAIL 06095 08-01-30 11-58-23 INP ALAIL 06095 08-01-30 11-58-23 OPTEX= RES ALAIL 06095 08-01-30 11-58-24 CEN=1/08-01-30/11 H 58 MN 19/STORED ALARMS LIST PROCESSING TPFFIR ACC ! *A0628/540 /07-12-17/15 H 58/N=7598/TYP=ICT/CAT=SI/EVENT=MAL /NCEN=MULCT /AM =SMTA1/AGEO=S1-TR01-B03-A085-R000 /TEXAL=AIS/COMPL.INF: /AF=URMA1 / ICTRQ AGCA=S1-TR01-B03-A112-R065 /AMET=01-07-02 /AFLR=222-09/CRC=NACT !!! *A0628/303 /07-12-17/15 H 46/N=7501/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 4/AGEO=BUDLASAN-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=3 !!! *A0628/306 /08-01-23/07 H 20/N=9619/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFCN =CNLM3-4/AGEO=MKRASHID-B02-A003 /TEXAL=CN ISOLATED !!! *A0628/303 /07-12-17/15 H 46/N=7503/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 12/AGEO=KHOTYWAL-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=0 !!! *A0628/089 /08-01-29/22 H 14/N=1760/TYP=ENP/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 11/AGEO=QADIRPUR-B01 /TEXAL=GENERATING UNIT !! *A0628/320 /08-01-17/13 H 47/N=8062/TYP=COM/CAT=ID/EVENT=MAL /NCEN=MULCT /AFUR =URAL- 15/AGEO=S1-TR01-B04 /TEXAL=FAULTY UNIT/COMPL.INF: * #F0612/T11F14/NCEN=MULCT /08-01-30/11 H 33/NAM=ODCAB /TDA=0001 /N=7064/NIV=2/ENS=006/SENS=013-000-000/P='0228'H/CN=02/PAR='03'H /EM: AFUR =URAL- 15 !!! *A0628/303 /07-12-17/15 H 46/N=7506/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 7/AGEO=ADABOSAN-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=2 !!! *A0628/303 /07-12-17/15 H 46/N=7507/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 11/AGEO=QADIRPUR-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=2 !! *A0628/320 /08-01-26/06 H 39/N=0566/TYP=COM/CAT=ID/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 14/AGEO=KHOKARAN-B01 /TEXAL=FAULTY UNIT/COMPL.INF: |
|
||||
|
actually i want you to have a complete understanding of my problem cozi am beginer & i am still stucked
![]() i have no problem with using space i.e Code:
: #!/bin/bash alarm= `cat ~/alkatel.txt Code:
: #!/bin/bash alarm=`cat ~/alkatel.txt these codes display file contents which is fine but the main problem is to extract string components from file which i couldnt plz read the first thread i posted in very much detail to help me i realy need this help waiting for your reply very soon Last edited by nabmufti; 02-08-2008 at 08:59 AM.. Reason: to make code clear |
|
||||
|
following the script i got here worked well in getting file input
Code:
#!/bin/bash
alarm= `cat ~/alkatel.txt`
echo $alarm | while read line
do
{
echo $line
}
done
but will you plz help me in extracting the whole string following ! , !! or !!! coz i can only extract just one letter at my best using code the example of file im trying to extract strings is given above more i am trying to use cut command to extract string components in file. can i use this command to extract a complete log of alarm from file e.g. !!! *A0628/303 /07-12-17/15 H 46/N=7501/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 4/AGEO=BUDLASAN-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=3 i want to extract the string in this way above i used the command cut to extract date and time from the file as Code:
cut -b 16-32 ~/alkatel.txt /07-12-17/15 H 46/ T /AFUR =URAD- 4 hope u will understand my problem ![]() please read the threads above , to be sure about solution of my problem |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|