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 record. Here's a sequence of
three records from the input file:
S1830031HN106P S1830032HN113XTA S1830033MEI A
And here's the section of code that breaks the record into various parts,
with "InputLine" representing the record:
So the code should assign the characters in columns 9-13 to the var5
variable. The problem is that when the third record above ("S1830033MEI
A") is processed, the var5 should be assigned "MEI ", but ends up getting
assigned "MEI A". In the record, there are four spaces between the "I" and the "A", but the cut command seems to compress the consecutive whitespaces into one space, which then makes the "A" the fifth character in the variable. Is there a way to force the cut command to count each whitespace as a column, or some other simple way to assign exactly those characters in columns 9-13 to var5? I tried using various options with the cut command, but wasn't able to get the results I needed. I appreciate any help anyone can give.
There is a text file in my project named as "mom.txt" in which i want to have contents like..................
LSCRM(Application Name):
1: This is my first application.
2: Today we did shell scripting automation for this app.
3: It was really a good fun in doing so.
4: Really good.| (Here i... (7 Replies)
Hi Friend ,
i have one file say xyz.lst and it has content like
dn: cn=m.hariharan,cn=employee,cn=delhi circle,cn=users,dc=industowers,dc=c
dn: cn=ajay.jain,cn=employee,cn=gujarat circle,cn=users,dc=industowers,dc=com
dn: cn=ajitkumar.thakor,cn=employee,cn=gujarat... (4 Replies)
I am writing a shell script to skip couple of feilds in a flat file and as a part of this I have written the below piece of code in it.
cut -d '|' -f 1-17,19-31 $1 > filename
To add pipe at end of the line I used below command, but it adds even to header and footer as well which i... (11 Replies)
Hi,
I have used expr command to increment the date.
for e.g.,
case 1 :
echo $(date -d $(echo `expr 20010101 + 1`))
it returns
Tue Jan 2 00:00:00 IST 2001
case 2:
echo $(date -d $(echo `expr 20010101 - 1`))
it returns
date: invalid date `20010100'
please suggest me, how to... (3 Replies)
Hi!
I get a md5 hash of a file with this command:
openssl md5 /Users/me/MyLogo.png | cut -f 2 -d ' '
"cut" because I just want the hash. But there is a problem -> that doen't work with a path with spaces:
openssl md5 /Users/me/MyLogo 2.png | cut -f 2 -d ' '
The result is "2.png)=" ...... (1 Reply)
Hi
I have a strange problem when using cut command
when i am using the below command, it is working fine,I am getting the data in new file xyz.dat
cut -c 1-75 abc.dat > xyz.dat
when i am using the below command, I am getting the data in new file abc.dat , but empty file
cut -c 1-75... (4 Replies)
Hi Guru's,
I 'm trying to execute the below given script in Unix. I am having an issue with the script. The output of the script is given below:
#!/bin/bash
File_Home="/home/essftp/Risk"
cd /home/essftp/Risk
rm -f FileList
rm -f credit_risk*
file1=`ls -lt... (4 Replies)
Guys,
I've a problem in the "sed" command used in my shellscripts
This is the problamatic line in my shell script:
sed -e 's/${line1}/${line1_m}/g' prod_hier_1234.txt > test.txt
It doesn't do the job of replacing the string stored in variable 'line1' to 'line1_m'.
However If I replace the... (10 Replies)
I am trying to take one part of my text from file and save it to variable $x
I tryed this...
x=`cut -c 6-9 $fajl`
my file looks like this
fajl:
21890001277 89386911 23638FBCDC 28EE01A1 0000 26855 124 244326
21890001277 89766911 23638FBCDC 28E021A1 0000 26557 134 684326
21890001277... (7 Replies)
Hi all!
Here is my problem :
$ more file
yougli:passwd:123456:3265:Yepa Yepo:/home/yougli:/bin/ksh
As you can see, in the field "information", there are two spaces between "Yepa" and "yepo".
My problem is :
$ PARAM='more file | cut -d":" -f5'
$ echo $PARAM
Yepa Yepo
Now i only... (2 Replies)