String operation in csh AIX 4.3.2.0


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String operation in csh AIX 4.3.2.0
# 1  
Old 02-22-2017
String operation in csh AIX 4.3.2.0

Hi to everybody
i stuck on a simple thing i had a string and i want cut it , i try already few thing with the cut command but does not the way it should.
The script is in csh and running on AIX 4.3.2.0

here are few samples how the string can look like

Code:
FT71;1;1;1;;;1;31.01.2017 11:12:24;0
FT71;1;1;1;2;;1;31.01.2017 11:12:24;0
FT71;1;1;1;2;2;1;31.01.2017 11:12:24;0

The string should be cut always after the 7. delimiter even if there are no number between two delimiters like in sample 1 and 2 . That maybe the reason it doesnot works with the cut command.

Thanks a lot in advance




Moderator's Comments:
Mod Comment Start using code tags, thanks.

Last edited by rbatte1; 02-24-2017 at 01:17 PM.. Reason: Removed SIZE in code block
# 2  
Old 02-22-2017
Moderator's Comments:
Mod Comment Sorry for moving around your thread, i wrongly thought it deals with the same problem as your other thread.


Quote:
Originally Posted by Nadielosabra
The string should be cut always after the 7. delimiter even if there are no number between two delimiters like in sample 1 and 2 . That maybe the reason it doesnot works with the cut command.
This is actually exactly the way cut works:

Code:
# printf "\"%s\"\n" $(echo "1;2;3;;;6;7;8" | cut -d';' -f1)
"1"
# printf "\"%s\"\n" $(echo "1;2;3;;;6;7;8" | cut -d';' -f4)
""

You probably didn't interpret the returned empty string as a result, like i did above in the little proof of concept.

Anyway, i strongly suggest you stop using csh and start using a less bugridden shell. AIX 4.3.2 (you might want to consider updating this to 4.3.3 ML12 too) offers a ksh88 and a ksh93.

I hope this helps.

bakunin

Last edited by bakunin; 02-22-2017 at 08:31 AM..
This User Gave Thanks to bakunin For This Post:
# 3  
Old 02-22-2017
You are working with the same data as in your other thread, looks like.

Another way to do it is
Code:
$ echo "FT71;1;1;1;;;1;31.01.2017 11:12:24;0" | awk '{ NF=6 } 1' FS=";" OFS=";" -

FT71;1;1;1;;

$

This has no benefits over cut if that's all you're doing... but if you're doing 93 more transformations on the data before you're done with it, they could all be rolled up in one awk call instead of 93 more shell externals.
This User Gave Thanks to Corona688 For This Post:
# 4  
Old 02-23-2017
Hi Corona688,

thanks a lot for your help and Support,

Yes you are right the same string was in the other thread and your solution works perfect .
the cut on the string has to done every Iteration the change of the bit only has to done depending on some condition.


But the solution for the cut does not works on my side

Code:
 awk '{ NF=6 } 1' FS=";" OFS=";" $PATH_FILE > $TEMP_FILE

both file are the same , any ides what could be wrong

thanks in advanced

Last edited by rbatte1; 02-24-2017 at 01:16 PM.. Reason: Removed font formatting in CODE block
# 5  
Old 02-23-2017
Quote:
Originally Posted by Nadielosabra
But the solution for the cut does not works on my side
The routine is always the same: please post some sample of your input and a terminal session with some command executed on this data and its oucome: error messages, return codes, diagnostics and whatever is there.

Something like this:

I can't seem to make the ls-command work:
Code:
root@system # ls -l /bla/foo/file
/bla/foo/file not found
root@system # echo $?
2

Such a transcript i can analyse and would tell you that you probably mistyped the filename or some part of its path name. Telling me just "ls -l didn't work" i wouldn't be able to tell you anything.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 6  
Old 02-24-2017
Show field 8 and higher
Code:
cut -d";" -f8- file

This User Gave Thanks to MadeInGermany For This Post:
# 7  
Old 02-25-2017
Thanks for your help

I guest i found the reason why the cut and awk doesn't work on my Project.
The file has only one line with without an CR.
If i just add an CR to this line both cut and awk works as from you recommented.
My Problem now the other process which create this text file will not add an CR to the this line

I'll Play around , hopefully i will found a solution for it

Kind regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String operation in csh shell

Hi, to everybody i have a string which Looks like this FT47;3;1;1;;;1;09.02.2017 21:21:19;2;2 and i would like to change to value on one Position only e.g. the values on Position 6 should change to 1 nevertheyless which values was there before AIX 4.3.2.0 and csh i try... (10 Replies)
Discussion started by: Nadielosabra
10 Replies

2. AIX

AIX 6, operation on time in script

Hi I have a question, On linux (centos) I am executing a script: #!/bin/bash st1=`date "+%T"` SD=`date -u -d $st1 +"%s"` #some operations ... st2=`date "+%T"` FD=`date -u -d $st2 +"%s"` time_oper=`date -u -d "0 $FD sec - $SD sec" +"%H:%M:%S"` echo "Time script execution -... (1 Reply)
Discussion started by: primo102
1 Replies

3. Shell Programming and Scripting

String Operation

/home8/mc09ats/UnixCw/file4 this is the path...i have 2 variables filename and filepath...i want filename=file4 filepath=/home8/mc09ats/UnixCw i.e. i think i have to find last occurence of "/" in string and the string after "/" want to take in some variable and string before last "/"... (4 Replies)
Discussion started by: AbhijitIT
4 Replies

4. Shell Programming and Scripting

Help - Search for string, then do string operation on line

Hi, I wish to find all lines that contain a specific search word, and then do few string operations on that line. The idea is to "fix" the file which has been moved from windows to unix. Using unix - Sun Solaris Test input ("t2.sas") statement1 statement2 libname yahoo ... (6 Replies)
Discussion started by: deepaksinbox
6 Replies

5. UNIX for Dummies Questions & Answers

string operation

I am trying to ask for full name in a script, Then echo back to the user with the surname only, omitting the first name. Thanks (2 Replies)
Discussion started by: orjnet
2 Replies

6. Shell Programming and Scripting

string operation

i am new user of unix.i have a question.My script is- export STR_ALFA=`head -2 "${FILE_PATH}"|tail -1|cut -d"," -f1` "${TEST_HOME}"/function/chk_alfa.ksh STR_ALFA now i want to check STR_ALFA: 1)whether is alphabetic 2)whether is numeric 3)whether is alphanumeric... (1 Reply)
Discussion started by: arghya_owen
1 Replies

7. Shell Programming and Scripting

string operation

i am new user of unix.i have a question.My script is- export STR_ALFA=`head -2 "${FILE_PATH}"|tail -1|cut -d"," -f1` "${TEST_HOME}"/function/chk_alfa.ksh STR_ALFA now i want to check STR_ALFA: 1)whether is alphabetic 2)whether is numeric 3)whether is alphanumeric... (1 Reply)
Discussion started by: arghya_owen
1 Replies

8. Shell Programming and Scripting

string operation

Hi all, Here is my situation. I have a text file TXT_FILE like this: john 123456 jack 94589 kelvin 94595 mary 88585 I want to read the first word in each line ( the name ) and assign to a string variable ( EX_LIST ) in my script so that I can use later as this commandfor i in... (6 Replies)
Discussion started by: fongthai
6 Replies

9. AIX

AIX 5.3 errpt full of message: DISK OPERATION ERROR

Hi All, Can anyone explain me the meanning of the following errors: LABEL: SC_DISK_ERR2 IDENTIFIER: B6267342 Description DISK OPERATION ERROR Probable Causes DASD DEVICE Failure Causes DISK DRIVE DISK DRIVE ELECTRONICS Recommended Actions PERFORM PROBLEM DETERMINATION... (1 Reply)
Discussion started by: gianlu
1 Replies

10. AIX

AIX 4.3 Openssh 3.7.1.0 Operation

I am new/just getting used to this group (Unix Forums), but did search around. I saw a listing for "openssh for AIX" in which a response indicated a link was posted in the original post, but I couldn't find that link or another "original post", so first, if someone could enlighten me why I couldn't... (2 Replies)
Discussion started by: ripley
2 Replies
Login or Register to Ask a Question