logo
down
shadow

How to stop $ / being stripped of a string being inserted into a file with sed?


How to stop $ / being stripped of a string being inserted into a file with sed?

Content Index :

How to stop $ / being stripped of a string being inserted into a file with sed?
Tag : bash , By : user150744
Date : January 12 2021, 07:00 PM

it helps some times The Aim I am trying to write a bash script to automate the setup of a Raspbian system. This includes setting a custom prompt for all users. I need to change one line in the /etc/bashrc file. , So, the following works:
cat <<'EOF' |
if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
   PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

fi
EOF
sed 's/\([[:space:]]\+\)PS1=.*/\1#&\n\1PS1='\''[e[36;40m][e[m][e[93m]@[e[m][e[36m]h[e[m]: [e[92m]w[e[m] [e[92m]$[e[m][e[93m]>[e[m]'\''/'
if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
   #   PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
   PS1='[e[36;40m][e[m][e[93m]@[e[m][e[36m]h[e[m]: [e[92m]w[e[m] [e[92m]$[e[m][e[93m]>[e[m]'

fi
  custom_prompt="  PS1='${debian_chroot:+($debian_chroot)}\[\e[36;40m\]\u\[\e[m\]\[\e[93m\]@\[\e[m\]\[\e[36m\]\h\[\e[m\]: \[\e[92m\]\w\[\e[m\] \[\e[92m\]\\$\[\e[m\]\[\e[93m\]>\[\e[m\]'"
  # replace each \ for double \\
  sed_custom_prompt=$(<<<"$custom_prompt" sed 's/\\/\\\\/g')
  sed 's/\([[:space:]]\+\)PS1=.*/\1#&\n\1'"$sed_custom_prompt"'/'

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to stop the leading 0's from being stripped off when exporting to excel from a datatable?


Tag : chash , By : John Miller
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I don't know the output of your XSL transformation: I will assume it's the xml format for Excel. Trying to reverse the process I wrote three numbers (007) in an Excel sheet: once as number, once as text and once as number but formatted to show 3 digits padded with zeros. Then I saved it as xml and looked at it. Here is the fragment:
<Row>
    <Cell><Data ss:Type="Number">7</Data></Cell>
</Row>
<Row>
    <Cell><Data ss:Type="String" x:Ticked="1">007</Data></Cell>
</Row>
<Row>
    <Cell ss:StyleID="s22"><Data ss:Type="Number">7</Data></Cell>
</Row>
writer.WriteString("\"");
writer.WriteString("=\"");

Tag : c , By : user181445
Date : March 29 2020, 07:55 AM
like below fixes the issue I don't see you link line so i's hard to tell for sure but this seems like it could be an ordering problem
If all of the symbols that are needed by libb are in liba, then you should list libb first, so that they are listed as symbols-to-be-resolved, and when libb is visited they will be resolved. This is not stripping per-se, it is just not including (i.e. it is omission not an active removal, am I splitting hairs? maybe)

How to stop leading 0's from being stripped from my integers in C#


Tag : chash , By : Anthony Eden
Date : March 29 2020, 07:55 AM
should help you out I am trying to store integers representing 4 bit strings, some of which have 0's at the beginning. When I write these values out in the Console the leading 0's are stripped off, can I stop this from happening? I read through the documentation but couldn't see anything that would prevent this from happening. Here is my code so far: , try with
Console.WriteLine(i.ToString("D4"));

How to stop spaces,\n getting stripped from Unit Test Session Output?


Tag : fhash , By : lhoBas
Date : March 29 2020, 07:55 AM
hop of those help? Simple wrapping of C# Console behaviour in F# printfn style.
NB. the printfn "no format" overload is not working for this work-around.
    // .fs code
    // --------

    namespace Play

    open PlayCS
    open System
    open NUnit.Framework

    module printHelper =
      let printfn (fmt: Format<_,_,_,_>) x = ConsoleHack.WriteLine <| sprintf fmt x        
    open printHelper

    [<TestFixture>]
    type  printPatterns2() =
      [<Test>]
      member __.testHelper() = 
        printfn "%s" "our overloaded printfn"
        printfn "%s" "now does"
        printfn "%s" "what"
        printfn "%s" "it is supposed to"
        printfn "%s" "in the F#/Resharper/nunit context"

      [<Test>]
      member __.testHackWriteLine() = 
        ConsoleHack.WriteLine(sprintf "%s" "abc")
        ConsoleHack.WriteLine(sprintf "%s" "abc")

    // .cs code
    // --------

    using System;

    namespace PlayCS
    {
        public class ConsoleHack
        {
            public static void WriteLine(string s)
            {
                Console.WriteLine(s);
            }
        }
    }

Saving stripped text from csv file as a string object with Python


Tag : python , By : John Bentley
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I'd like to be able to save text from a file that I had to retrieve from online and decompress (part of an assignment), in order to carry on with my next steps. Specifically, I'd like to save it as its own string object. , You could use a list, and append each line of text to the list.
my_text = []
for line in seq:
    my_text.append(line.strip())
Related Posts Related QUESTIONS :
  • How to create a new procedure from bash script
  • Sed command to uppercase text between two specific strings
  • Escape double quotes in a Jenkins pipeline file's shell command
  • pgrep -f cuts commands after 4095 characters
  • I want my script to echo "$1" into a file literally
  • Shell script: unexpected token ´if"
  • scp error when defining a "PATH" variable in a bash script
  • Nested loop for reading two files with bash
  • Find folders with a specific name and run bash commands on each location
  • Replication and expansion of program flags in BASH script
  • Error on certain line: Syntax error: "(" unexpected
  • Terminal not returning to normal after Bash Script
  • what code function will help to ask for input when i try to execute a code with no previous value in shell script
  • “How to fix ‘Syntax Error Near’ error in BASH”
  • How to generate all ASCII characters with a brace expansion?
  • Why does `export` fail on bad substitutions but not command failures?
  • I am trying to get a public IP from an instance I am just starting up
  • How to run a bash script, but skip the last 2 lines?
  • Google Cloud Storage - Create many copies of a single object/file quickly
  • find all matches between two files then append character to beginning all matches in the second file
  • How to print 02-Jun-2019 in bash
  • added wrong path to .bash_profile now I can not found any command
  • How can I pick every line of a file with a match and do operations with it?
  • How to use awk and read together in bash script?
  • syntax error near unexpected token `(' when defining function in bash profile
  • How can I read a stream of key=value pairs in bash if the values can be empty?
  • How to get last sunday's date from today's date using shell script?
  • How to exec bash script w/o exiting shell
  • How to use an external variables file inside a script
  • How to run commands in parallel in bash?
  • mkdir no such file or directory syntax error?
  • How to write for loop to fetch data to newly created file?
  • Translate git-log old commiter timestamp to strict ISO 8601 timestamp
  • move files that no not contain specific string
  • How to group by one column and divide the numbers in second column depending from the third
  • Bash get the command that is piping into a script
  • while read line not working on mac with makefile
  • How to redirect A's stdout to B's stdin and B's stdout to A's stdin?
  • echo is not entered into hash table
  • sed an remove everything after the first pattern (only in the line)
  • Bash using cut to separate an IP and Port
  • Can a shebang refer to a remote program?
  • Why I am not getting a value when i call a function within another in a bash script
  • Why does ". myscript" return file-not-found in only one Git for Windows sh.exe?
  • How to parse a rdf format file from command line
  • Unknown shorthand flag: 'd' in -d
  • Why does a pipeline reading from and writing to the same file result in a blank file?
  • why the code inside EOF shows this error?
  • Why should I add wait after done?
  • Script bash : Remove numbers from a file name between "-" and "_"
  • How to pass multiple commands to a single command in bash using &&?
  • Bash Conditional Odd Behavior
  • Shell script read multiple inputs from user
  • Passing variables with spaces to function
  • Is the term trap (of Bash) more accurate than the generic "callback" term in programming?
  • How to extract only specific string matching lines from a multiple lines standard input
  • $BASH_VERSION reports old version of bash on macOS, is this a problem that should be fixed?
  • Using awk to get lines between two patterns
  • -bash: emacs.profile: command not found
  • Write a script (or a command)
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com