First of all thankyou for your time ! Here i didn't understand what you told that 7 vertical bars. Its like suppose in my text file , i have data that looks like:
... ... ...
So, plz reply with any command that can help me get the desired value.
Thanks
Moderator's Comments:
Seriously: Please use CODE tags as required by forum rules!
The data that you have in your text file and the commands you are using to extract data from that text file do not seem well suited to what you are trying to do. Please create a file named test.txt that contains the following text:
After creating that file, what output do you get when you run the command:
What output do you get when you run the command:
What output do you get when you run the command:
After running these commands do you understand what I meant about the 6 vertical bars (AKA pipe symbols)? Do you see that the cut commands in your script are extracting data from 7 pipe symbol delimited fields from lines in the input you feed into it, but only two of those lines contain any pipe symbols?
Have you read the manual page for cut on your system? If not enter the command:
and look at how it describes the -d, -f, and -soptions. I know that you aren't using the -s option in your code, but (with the possible exception of when you are extracting field 1 data) you might want to consider it. Do you understand now what I meant when I said "you are trying to extract data from seven vertical bar separated fields in your input file"?
Last edited by Don Cragun; 06-04-2017 at 01:43 PM..
Reason: Fix typo: s/7/6/
hello..
my prob is as follows:
i have to read from a file which may have different formats depending upon the delimiter used in the data of the file.now i need that the user input the delimiter.the input delimiter is stored in a variable and is used on cut command to retrieve necessary... (3 Replies)
Hi All,
Can the cut command have double character delimiter?
If yes, how can we use it.
if my data file contains :
apple || mango || grapes
i used
cut -f1 -d"||" filename
but got an error.
Plz help....
Thanks. (1 Reply)
We are facing a problem with PIPE (|) as a delimiter in one of our FTP flat files.
We are constructing a Flat file in IBM-AIX and this contains various strings delimted by PIPE Symbol and then FTPing this to a Mainframe System
The Mainframe program simply recieves this and FTPs the same... (1 Reply)
Hello All,
I have a file with thousands of records:
eg:
|000222|123456987|||||||AARONSON| JOHN P|||PRIMARY |P
|000111|567894521|||||||ATHENS| WILLIAM k|||AAAA|L
Expected:
|000222|123456987|||||||AARONSON| JOHN |P|||PRIMARY |P
|000111|567894521|||||||ATHENS| WILLIAM |k|||AAAA|L
I... (6 Replies)
I am trying to extract 'postmaster' from the following string:
PenaltyError:=554 5.7.1 Error, send your mail to postmaster@LOCALDOMAIN
using the following command:
cat /usr/share/assp/assp.cfg | grep ^PenaltyError:= | cut -d '@' -f1 | cut -f8
but it returns:
PenaltyError:=554 5.7.1 Error,... (10 Replies)
I'm new to shell programming, and am having a problem in a (Korn) shell program, which boils down to this:
The program reads a record from an input file and then uses a series of
"cut" commands to break the record into parts and assign the parts to
variables. There are no delimiters in the... (2 Replies)
Hi,
I've a situation where,
a=xxx.yyy.zzz.txt
EXTN=`echo $a | cut -d . -f2`
Using the above code it delimites and will return "yyy.zzz.txt" to EXTN. But i need to get only the extension "txt". so as per the above code it delimits in the first "." itself. Can anyone help how to do... (6 Replies)
I can not make it work, it prints \t rather than introduce tabs.
cut -d "," -f 4,8 Samples.csv --output-delimiter="\t" | sort > out
Since I am running this command within a shell script, I tried manually inserting tab in this command, still does not work. I am using bash shell
Suggestions... (8 Replies)
Hi all,
I have a number of strings like below:
//mnt/autocor/43°13'(33")W/
and i'm trying to get the numbers in this string, for example
431333
please help
thanks ahead (14 Replies)
Hi All,
We have a requirement of picking nth position value by using cut command. value would be delimited by any symbols. We have to pass delimited value and postition to get the value in a string.
ex.
echo "A,B,C,D,E" |cut -d "," -f3
echo "A|B|C|D|E"|cut -d "|" -f2
Kindly frame the... (5 Replies)