cutting out the last field


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cutting out the last field
# 1  
Old 06-07-2005
cutting out the last field

Hi all;

i was asked to install an inventory tool on our Reliant Unix 5.45 server. I downloaded the file from our intratnet.
It was always failing when i try to install it.
After some investigation i saw that the installation script had something strange.
When i "cat <script>" i see nothing wrong.
When i "vī <script> " i see that each line of the script ends wiht ^M i guess this is a Carigage return....

I tried to use :
sed '/^M/d ' <script> >> <script1> and when i "vi <script1>" the problem is still there and i alway see ^M at the end of each line.

Can somebody tell me how can i remove this ^M ???

Thanks in advance.
# 2  
Old 06-07-2005
In most flavour of *nix, you will have a caommand calles dos2unix or dos2ux.
You can run this on the file to remove these.

if your scrip is called sript.sh this out be:

dos2unux script.sh script.sh ( yes the filname should be here twice)

or failing that you could do

sed 's/^M//g' script.sh > newscript.sh

(^M is produced by typing ctrl+v then ctrl+m)
# 3  
Old 06-07-2005
The problem is file is in DOS format. You can change it as,

dos2ux <filename> > <outputfile>

hth.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cutting field

Hi, I have a var sdt='23032011000000' now if i want only 23 out of above? hw to cut? also..after cuttint-will it be stored in another var as a varchar or as a number? (4 Replies)
Discussion started by: musu
4 Replies

2. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

3. UNIX for Dummies Questions & Answers

Help with cutting a string

Hi All, I have a string in the following format "abcd | fghfh | qwer | ertete" I need to cut the values in the following format line1 = abcd | fghfh | qwer line2 = ertete Simply speaking a want to cut all the values before the last delimiter from the line and print it on one line and... (11 Replies)
Discussion started by: amit_kv1983
11 Replies

4. Shell Programming and Scripting

Cutting the value from a string

Hi all I have a string variable ${WHERE_SQL1} where i want to cut the first value of a variable. Eg ${WHERE_SQL1} = 'Where a.id =.................' I the string to be 'a.id =.......' Thanks in advance (2 Replies)
Discussion started by: theeights
2 Replies

5. Shell Programming and Scripting

cutting lines

Dear All, Is there a way to cut the lines that have been "head" Here is what i m trying to do Please advice there is file name dummy.txt now i am trying to head this file 4 time by using a loop and every time this file is head with different values e.g in first instance it will... (7 Replies)
Discussion started by: jojo123
7 Replies

6. Shell Programming and Scripting

Need Help in Cutting a word

Hi All , i am working on a backup script , which would a call a executable file in unix server , Login credentials :: use telnet session to login to Unix server when logged in, this would be my Prompt ::: unix11@raghav: I just need to cut the word unix11 , so that i can use this... (12 Replies)
Discussion started by: raghav1982
12 Replies

7. Shell Programming and Scripting

problem cutting

echo $line|cut -d " " -f`$plannedCount`- and this is the output $ ./read.sh ./read.sh: 12: not found JADE TRADER 143W MYPEN 40 HC M X10 28 7 1 0 ./read.sh: 9: not found MYPEN 20 GP X X10 15 2 1 0 ./read.sh: 9: not found MYPEN 40 GP X X10 28 7 1 0 ./read.sh: 9: not found MYPEN 20... (6 Replies)
Discussion started by: finalight
6 Replies

8. UNIX for Dummies Questions & Answers

cutting

Is there any cut or awk function that would allow me to take the last part of a path away and save the list into a file? I wrote: find $HOME -mtime +3 > fileList cat fileList /home/102/s/jn/folder/HW /home/102/s/jn/otherfolder/B.txt /home/102/s/jn/folder4/3dA/w... (1 Reply)
Discussion started by: terms5
1 Replies

9. Shell Programming and Scripting

Cutting Up a String

I have a file name coming in as such <string>_YYYYMMDD.DAT The string could be anything. I want to cut out the date and put it in a variable. Can someone help me with this? (4 Replies)
Discussion started by: lesstjm
4 Replies
Login or Register to Ask a Question