Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.linux.slackware > #26509
| From | no.top.post@gmail.com |
|---|---|
| Newsgroups | alt.os.linux.slackware, comp.os.linux.misc, alt.os.linux.debian |
| Subject | Re: bash script problem ? |
| Followup-To | alt.os.linux.slackware, comp.os.linux.misc, alt.os.linux.debian |
| Date | 2016-03-16 16:52 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <ncc30j$gho$1@dont-email.me> (permalink) |
Cross-posted to 3 groups.
Followups directed to: alt.os.linux.slackware, comp.os.linux.misc, alt.os.linux.debian
In article <>, Joe Beanfish <joebeanfish@nospam.duh> wrote:
> On Thu, 10 Mar 2016 13:20:58 +0000, no.top.post wrote:
> > I want to launch from a bash script:
> > xterm -e mc <Path1> <Path2>
> > where <Path1> = dirname `head -1 /root/.mc/filepos |awk '{print $1}'`
> > and <Path2> = dirname `head -2 /root/.mc/filepos |awk '{print $1}' |
> > tail -1`
> >
> > I.e. the 1st token of the 1st & 2nd line of /root/.mc/filepos are args
> > of mc The following 4 lines fail:-
> > Path1=dirname `head -1 /root/.mc/filepos |awk '{print $1}'`
> > Path2=dirname `head -2 /root/.mc/filepos |awk '{print $1}' | tail -1`
> > xterm -e mc `dirname $Path1`
> > xterm -e mc `dirname $Path2`
>
> Drop the extra dirname from the Path* assignment
OK, What was I doing there ?!
You can peel-the-potato before OR after cooking; but not both.
>
> Path1=`head -1 /root/.mc/filepos |awk '{print $1}'`
> Path2=`head -2 /root/.mc/filepos |awk '{print $1}' | tail -1`
> xterm -e mc `dirname $Path1` `dirname $Path2`
>
> You could simplify the commands a bit with
>
> Path1=`awk 'NR==1 {print $1;exit 0;}' /root/.mc/filepos`
> Path2=`awk 'NR==2 {print $1;exit 0;}' /root/.mc/filepos`
> xterm -e mc `dirname $Path1` `dirname $Path2`
OK: but 'awk punishes me'. Save human memory is best.
>
> The dirname step could also be eliminated in awk but isn't worth
> the effort to make it robust when dirname is available.
Correct: human effort is the criterium.
Thanks.
Back to alt.os.linux.slackware | Previous | Next | Find similar | Unroll thread
Re: bash script problem ? no.top.post@gmail.com - 2016-03-16 16:52 +0000
csiph-web