Csh - how to combine multiple commands in one line
Hey everyone,
I am working in an environment where the different users can use ksh or csh. My situation is that I need the same result with one single command line.
I am searching for the real path the file is in.
My ksh input and output
My csh input and output
It seems that csh does not support such "fancy" things as combining multiple commands in one line.
I already tried the following calls
with just two commadns combined it seems to be working.
Can anyone help?
---------- Post updated 05-02-16 at 06:59 AM ---------- Previous update was 04-02-16 at 12:24 PM ----------
I found a workaround for this. I am currently using
This was the best I could whink of.
If anyone has an other idea, I am willing to try everything to make this a little smoother.
As you have seen, and as has been said many times before in this forum, csh is more intended for interactive use. And, shells based on Bourne shell syntax (such as ash, bash, dash, ksh, sh, and many others) are much easier to use for shell scripting.
Why not just use ksh instead of trying to convert working ksh scripts to csh?
You do know that if you have a script starting with:
in an executable file, that file can be invoked by a csh script or by a ksh script and will run with ksh interpreting the commands inside that script. Thinking that you should write a script in the common set of tools available to both csh and ksh so that code can be executed by both csh and ksh scripts produces a lot of busywork that will created slower scripts with much more restricted capabilities than just writing your scripts using ksh.
Last edited by Don Cragun; 02-05-2016 at 02:49 AM..
Reason: Add note.
Nested `commands` are problematic.
While ksh and bash allow the \ escape of the inner back-ticks, you have found the $(commands) that can be properly nested.
The csh does not even allow the \ escape of the inner back-ticks; nesting them is plain impossible. You have to use a variable for each step.
Once you have a variable, you can avoid the dirname by means of a variable modifier:
Tip: you better have no space around the = in a variable assignment, and have command arguments in "quotes". This is even true for ksh and bash:
Last edited by MadeInGermany; 02-05-2016 at 04:54 PM..
Reason: consequent quoting
This User Gave Thanks to MadeInGermany For This Post:
I have the following sh-script:
konsole -T todo -e vi todo.txt &
konsole -T window1 -e ssh user@server &
konsole -T window2 -e ssh user@server2 -e cd directory &
The first two lines are working fine. The first opens a txt-file, the second opens a ssh-connection.
The third line... (6 Replies)
I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice.
I've got a text file full of hundreds of events in this format:
Record Number : 1
Records in Seq : ... (3 Replies)
I am experimenting with some scripting as a way to learn more about it. I have a simple script that calls two other scripts. Each script echos some stuff to prove it ran and then sets a simple variable and exports it.
I cannot get one of the variables to display back in the main calling script... (2 Replies)
Hi There,
I have a cronjob that executes a small script (few lines) that I am certain can be achieved in a single line.
The functional objective is actually really simple;
cmd var1
The '1' in 'var1' is actually derived from date (day of month) but the snag is when working with 1-9 I... (3 Replies)
I'm working with a file with an xml structure. I'd like to parse it down to just the bits i want. Here is and example of the file
<message id="96352877" method="status">
<date rfc="Sat, 12 Mar 2011 16:13:15 -0600" unix="1299967995" />
<services>
<service id="facebook"... (4 Replies)
This is related to one of my previous post but now with a slight difference: I need the "Updated:" to be in one line as well as the "Information:" on one line as well. These are in multiple lines right now as seen below. These can have 2 or more lines that needs to be in one line.
System name:... (8 Replies)
Hi,
I want to make sed write a part of fileA (first 7 lines) to file1 and the rest of fileA to file2 in a single call and single line in sed. If I do the following:
sed '1,7w file1; 8,$w file2' fileA
I get only one file named file1 plus all the characters following file1. If I try to use curly... (1 Reply)