Please help with command like: cp <+ ... +> filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help with command like: cp <+ ... +> filename
# 1  
Old 03-10-2011
Please help with command like: cp <+ ... +> filename

Hi,
I am new to Unix platform. Currently, I got an job that really kills me: porting a script on MKS ksh to cygwin shell. This script contains:
cp <+
$A
$B
...

+> filename

It looks like gather all stuff between '<....>' to the file: filename. The script can run on MKS KSH, but it can't run on cygwin shell. My question is: How can I translate this part of script to cygwin shell?
Interesting thing is: I tried command
cp <+ 'xyz' +>filename
on MKS KSH. It can not run either. But why it is OK when I run the script. I am so confused.

Please help me.

Many thanks
jason
# 2  
Old 03-10-2011
I am not familiar with KMS system. But if $A $B ... are just ascii file, you can transfer the code using:

cat $A $B > filename
# 3  
Old 03-11-2011
Thanks for your help.
The script I am working on is a makefile. $A, $B are not files. They are variables and commands. This part of real script are:

@cp <+
-c
-o $@
-m $(@:b).map
-stack 0x100
$(ALL_OBJECTS:t" \n")
$(TMS_VERSION_OBJECT:t" \n")
-l $(TMS_LIB_DIR)/stdmthss.lib
-l $(TMS_STANDARD_LIBRARY)
....
+> tmp.0

Then the script process the file tmp.0.

jason
# 4  
Old 03-11-2011
If you have MKS up and running, you can remove the @ in front of the cp and that will display what these lines are actually doing.
# 5  
Old 03-11-2011
That looks like some weird extended syntax alternative to backslashes, to let a command cross several lines. If it works how it looks like it does,
Code:
command <+
       argument
       argument
       argument +> argument

is equivalent to
Code:
command \
        argument \
        argument \
        argument argument

# 6  
Old 03-11-2011
Thanks again for all response.
I think I should add more information here.
After this part of script runing, I can see the file tmp.0 looks like:

-c
-o hse.tms
-m hse.map
-stack 0x100
hseobj/hardware.obj
hseobj/main.obj
...
hseobj/version.obj
-l c:/j/c3xtools/lib/stdmthss.lib
-l c:/j/c3xtools/lib/tms450.lib
...

As you can see, the variables are all expanded($@=hse.tms, $(@:b)=hse, etc.). There are some conditional (ifeq..) excution too, all handled well. Except that, all other stuff recorded in file tmp.0.
I did try excute command on MKS KSH terminal like:
cp <+ \
-c \
+>tmp.0

I got error "can not open '+' for input". But the scrip running under command: make (targetname) is OK. So, I suspect that might regarding command 'make' under MKS.

jason
# 7  
Old 03-11-2011
Wait, this was a makefile? Might've been nice to know Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass filename as arguement to awk command?

Hi, I am facing one issue. The awk command works fine if i hardcode the file name but if is pass it as an arguement it doesn't work. For e.g:Below commands works fine awk -v A="$type" '{F=substr($0,23,8) "_LTD_" A ".txt"; print $0 >> F; close(F) }' RL004.txt But the below command does not... (2 Replies)
Discussion started by: Neelkanth
2 Replies

2. Shell Programming and Scripting

How to pass a filename as a command line argument

Hi,I have a script which is given below :#!/bin/bash. ini_script.shdb2 connect to $DB_NAME user $DB2_UID using $DB2_PASSWORDfor file in `ls -1 ./sql/ddw/`do echo "Executing the file $file" echo db2 -tvf $filedonedb2 quiti want this script to accept directorie's names present in... (1 Reply)
Discussion started by: ektubbe
1 Replies

3. Shell Programming and Scripting

Only filename from find command

Hi All When we use find command command in Unix we get the result as /home/user/folder/filename1 /home/user/folder/filename2 /home/user/folder/filename3 Is it possible that i only get the file name The expected output when using find command is filename1 filename2 filename3 I am... (13 Replies)
Discussion started by: parthmittal2007
13 Replies

4. UNIX for Dummies Questions & Answers

Command rm deletes filename but not the blocks

Hi It happens when I try to delete a file of 250MB with the command rm -r on our old Intergraph CLIX that the filename disappears while the blocks remain on the machine. Only when I reboot the system the blocks really disappear. Then rm works again for sometime but after some time it happens... (15 Replies)
Discussion started by: hausi2012
15 Replies

5. Shell Programming and Scripting

Howto get only filename from find command in Linux?

Hi every body! I would like to get only filename in the result of find command in Linux but I don't know howto. Tks so much for your helps. (5 Replies)
Discussion started by: nguyendu0102
5 Replies

6. Shell Programming and Scripting

how to get only filename in a recursively find command

Hi i would like to ask on how to accomplish the FF: I want to execute a find command recursively and only get the filename something like i want only the last field set if is used ever the fieldvset as an redirection from the output of the find command For example: dir1/dir2/filename1... (2 Replies)
Discussion started by: jao_madn
2 Replies

7. Shell Programming and Scripting

How to strip off the leading filename from 'wc -l' command

Hi... can anyone please tell how do i strip off the leading filename from the wc -l command.... when i fire command wc -l new1 ... its giving output as 14 new1 i want the output as just '14'... i need to use this value in the calculations in the later part of the script..... (2 Replies)
Discussion started by: swap21783
2 Replies

8. Shell Programming and Scripting

Change filename extensions..from command line

I want to change the extensions of a folder full of files (some of the files are located in subfolders as well) to another extension, but instead of replacing the files I want the new files to be copied into a newly created folder. Here is the folder structure: /Downloads/3eb... (3 Replies)
Discussion started by: bound4h
3 Replies

9. UNIX for Dummies Questions & Answers

How to get dir name tacked onto filename with ls command

hello i'm trying to figure out how to tack the directory name onto the file name when i do the ls -ltrR command please? --------------------------------------------------------------------------------- I do the following command ls -ltrR > ls.out and get the following output:... (5 Replies)
Discussion started by: bobk544
5 Replies

10. UNIX for Dummies Questions & Answers

Use same filename for prefix in the split command

I want to execute something like this: find . -type f -regex '$REGEX' -print | xargs split -d -C $SIZE The problem is that I want the name of the split files to be the same name as original files. So if my directory has two files called abc.txt and def.txt, then I want the split files to be... (1 Reply)
Discussion started by: namityadav
1 Replies
Login or Register to Ask a Question