Hyphen-minus passwd
Hi guys! Please, Can someone help me? How can I create this password with a hyphen in front? # openssl passwd -6 -salt username -password This is the response message when I try: passwd: Unknown option: -passwd Thanks for reply!
Re: Temporary color prompt in bash script
Thanks guys, but this is not the solution I'm looking for ... Now, I ask the question in other terms: Is It possible to print of a string at the exit of a bash script? e.g.: user@mypc: # bash script has just finished! [prompt] with the prompt that remains immediately after the string printed. Thanks, as always, for reply. > [...] > > > You have to source the script instead of running it. > > Yes, exactly. > > > I'm not entirely clear about a new shell gets it's own env that > > disappears when the shell exits thing, but try this: > > It's not only a shell thing. It's a basic Unix process thing: > child processes inherit (well, almost always) their parent's > environment -- more precisely a copy of it. They can change > their copy, but not the parent's. That's by design: lots of > loosely coupled programs calling each other (and that's what > Unix is, after all ;-) would degenerate into an unmaintainable > mess otherwise... > > > $ cat setps1 > > ##!/bin/bash > > # can i change ps1 from a script? > > echo "FOO = ${FOO}" > > export FOO=BAR > > echo "FOO now = ${FOO}" > > export PS1='\[\e]0;\u@\h: > > \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w > > #\[\033[91m\] ' > > > > $ export FOO=FOO > > $ ./setps1 > > FOO = FOO > > FOO now = BAR > > $ echo $FOO > > FOO > > > > See? FOO is back to it's pre ./setps1 value > > > > Now try > > $ source setps1 > > That's the way. There's a shorthand for "source", which is ".". So instead > of doing > > source setps1 > > you can say > > . setps1 > > Cheers > -- tomás >
Temporary color prompt in bash script
Hi guys! I'm trying, trying and trying but... How I Can put in hte end of a bash script this command: PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w #\[\033[91m\] " so that after finishing the script the prompt will write in red...? If I try in prompt # PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w #\[\033[91m\] " command no problem, write in red until exit or reboot. Thanks in advance for reply.
SOLVED !! Re: Delete all after a pattern
Thanks Roberto and Wanderer: $ sed 's/config=.*$/config=/g' file.txt was the solution...!! > On 2019-08-31 at 07:58, Roberto C. Sánchez wrote: > > > On Sat, Aug 31, 2019 at 01:49:20PM +0200, Computer Planet wrote: > > > >> Hi guys! Is It possible, with "sed" erase all after a pattern? I'm > >> trying in all way but I can't... I'd like to erase all after the > >> pattern "config=" but only in the same line, regardless of where it > >> is located inside in a file. > >> > >> Can somebody help me please? Thank in advance for reply. > >> > >> e.g.: after "config=" erase all until the end of the line > > > > Something like this: > > > > sed -E 's/(.*config=).*/\1/' > > Or perhaps > > sed 's/config=.*$/config=/g' > > ? > > Less elegant and idiomatic, but could also get the job done. > > The 'g' at the end is in case there can be multiple occurrences of > 'config=' in a single file, so that sed won't stop after the first one > it finds. > > > In practice, I'd either use this with 'sed -i [the above expression] > filename' or (more likely) with 'cat filename | sed [the above > expression] > newfilename'. > > (Yes, that's technically a "senseless use of cat". I do it anyway, > because always using pipes at every stage makes it easy to add or remove > filtering stages without having to adjust the syntax in another part of > the pipeline, and because it's easier to stick with that habitual > pattern than to change it up in the relatively few cases where I can be > sure that multiple stages aren't and won't be needed.) > > (And may I say that it's annoying to need to explain this every time, in > order to forestall being called out for "senseless use of cat"? Not that > I get called out for that here very much, but it does seem to happen > virtually every time I don't include an explanation...) > > -- >The Wanderer > > The reasonable man adapts himself to the world; the unreasonable one > persists in trying to adapt the world to himself. Therefore all > progress depends on the unreasonable man. -- George Bernard Shaw > >
Re: Delete all after a pattern
Yes, something like this $ sed -E 's/(.*config=).*/\1/' but something I had already tried but not work... On Saturday, 31-08-2019 at 13:58 Roberto C. Sánchez wrote: > On Sat, Aug 31, 2019 at 01:49:20PM +0200, Computer Planet wrote: > > Hi guys! > > Is It possible, with "sed" erase all after a pattern? > > I'm trying in all way but I can't... > > I'd like to erase all after the pattern "config=" but only in the same line, > > regardless of where it is located inside in a file. > > > > Can somebody help me please? > > Thank in advance for reply. > > > > e.g.: after "config=" erase all until the end of the line > > > > Something like this: > > sed -E 's/(.*config=).*/\1/' > > Regards, > > -Roberto > -- > Roberto C. Sánchez > >
Delete all after a pattern
Hi guys! Is It possible, with "sed" erase all after a pattern? I'm trying in all way but I can't... I'd like to erase all after the pattern "config=" but only in the same line, regardless of where it is located inside in a file. Can somebody help me please? Thank in advance for reply. e.g.: after "config=" erase all until the end of the line