General :: Echo Newline Character Not Working In Bash?
Mar 11, 2011
I have bash script which has lots of echo statements and also I aliased echo to echo -e both in .bash_profile and .bashrc, so that new lines are printed properly for a statement like echo 'Hello World' the output should be I even tried using shopt -s expand_aliases in the script, I am running my script as bash /scripts/scriptnm.sh; if I run it as . /scripts/scriptnm.sh I am getting the desired output.
I would like to append text to a file. so i wrote in bashecho text >> file.confHowever it doesnt leave a new line. So i can only do this once. How do i add a new line?
Using xsel I pass a selection into a variable. I then check that the variable includes an embedded newline to be sure that the selection returned by xsel is complete. If the selection content preceding the newline is just a single word, the check fails to detect the newline, thus
i have a script where i need to pass an argument "1234:-)"if i run this as ./shell.sh 1234:-)it wont work because invalid character. i need to handle this with expect utility so if i pass it as ./shell.sh "1234:-)"no issue in bash but expect does not recognize this.
When I am adding removing packages to get more hard drive space, this is not the first time I left too many pages open and it crashes on me. My son would fix it by typing in the terminal sudo something, but I want to know how to do this. The only thing not working is the add/remove packages at the moment. Here is what it said, E:dpkg was interrupted you must manually run 'dpkg--configure -a' to correct the problem E: _cache-open()failed please report. Please, could someone tell me how to get the default back or whatever. When I type in the terminal, it refused my password until I tried several times, plus, it finally says in the terminal No such command. Bash. No such command. I am hoping this question is one you do recognize the answer for.
I tried using Yum to remove the package. Like this:
To remove or uninstall a package:
Code:
yum -y remove ,package name>
Terminal goes: Bash syntax error near unexpected token `newline'
I have several (vhdl) files containing a pattern with newline characters that I need to replace by another pattern that also contains newline characters.
I start with something like:
Code:
I want to replace it by something like:
Code:
(I need to paste some lines)
As I need to do this (very) often I want to use a shell script.
I'm trying to get multiple numeric valued version information into a variable, all on the same line. I want for example $VERSION=3.1.0.01.002. I'm trying to pull seperate values from the file named version.properties, wherein the file contains;
I end up with the value of .002 ?? Seems like it's only getting the last portion because if I run the script thru "bash -x" I get: ... + VERSION=$'3 .1 .0 .01 .002 ' + echo $'3 .1 .0 .01 .002 ' .002
Ok, so I find myself ripping audio CDs frequently, which I then lame to mp3's to put on my media player. I usually define the --ta and --tl (artist and album) ID3 tags and batch encode each album, but don't bother with the track tags as I'd have to do each one seperately.
So, I'm working on a script to do all this for me, extracting info from 'pwd' etc. to fill in the blanks for --ta, --tl and --tt (track name). All is working well, except that I can't get sed to pass on the "" character to lame to escape spaces.
Here's what I've got so far: (trouble spot is bolded - no need to pay attention to the rest of it)
Code:
All this does is pass a 'space' on to lame, which it takes as an invalid argument.
A very strange problem started for me today. I SSHed into a server and could not type the letter 'i'. It would work fine if I was not in an SSH session, but consistently and repeatedly broke when I started SSH. I rebooted my machine, and the problem now occurs any time I'm using Bash, whether SSHing or not. For the record, I'm doing all this in the standard gnome-terminal.
First: it is not a problem with my keyboard. As you can see, I am perfectly capable of typing the letter 'i' in a browser window. In fact, capital 'I' works fine in bash as well. If I start nano from Bash, I can type the letter 'i' all day long, but when I exit to the Bash prompt, again I am unable to.
What's even more bizarre, I cannot even paste the letter 'i' into bash, either via Ctrl+Shift+v or by middle mouse clicking. This makes it impossible for me to type commands like 'vim' or 'exit'. Bash scripts, however, appear to have no problem with this particular character. Now, I've commented everything out of my .bashrc file, but that didn't help. I got rid of my custom .xmodmaprc file. Still nothing. Keyboard layout is U.S. English. I removed all Keyboard Shortcuts that involve the letter 'i'. Rebooted half a dozen times, still no luck.
My workaround at present is to use zsh instead of bash. Everything works fine with it, but I'd really like to get this thing fixed.
I have a BASH shell script with embedded SQL script. The SQL script fetches the data from oracle server and the data contains more than 8 spaces in the value (eg, 28051630 A) and the data is written to flat file using the below syntax:
The problem is that whenever the data is written to ${out_file} spaces are getting converted to TAB character
eg, 10 spaces (in Oracle) converted to 1 TAB and 2 spaces 7 spaces (in Oracle) converted to 1 TAB and 1 space Also, from above example you can see the width of TAB char is not constant (8 in first example and 6 in second example) Is there any way that I can stop shell script to convert spaces into TAB character as I want the data as it is from Oracle DB (i.e. only spaces not TABs)
Is there a way to process individual characters one-by-one from a text file in Bash, or is that hoping for a little too much from this lovable old clunker?
As exposed in a previous thread : 11.3 64b nvidia kde4 : font color bug in konsole I have a problem in the konsole terminal . I chose the Fixed [misc] font and i want the size 3. But for some unknown reasons konsole wants to display some chracaters and some words in bold . As This font doesn't exist in size 3 in bold, it displays the bold characters in size 7, which is the smallest available bold size for this font set (Fixed [Misc]) . It makes any of these bold characters unreadable as they are too large compared to the room they have to be displayed. How can i prevent konsole , bash , htop or any program responsible for this behaviour, to display such bold character ?
I am working with bash scripting and running into a weird issue where the trailing newline characters are being truncated.The file contents are something like:
Code: # Catting the file shows the trailing characters cat /tmp/junk first line second line
[Code]...
Since I am working with config files, some of the applications/daemons fail to start if they fail to find trailing newline characters
I've been playing around with sed but can't find a way to remove the <br> html tag and replace it with a newline. Sed isn't truly needed awk or other suggestions could be good.
Concatenating two files without creating a newline between them? So how is it possible to do that? I've tried the following: Code: echo 123 > file1 echo 456 > file2 cat file2 file2 > file3
I have a dell mini 10v with ubuntu. I have been trying reapteadly to try to get the ubutnu version of mana world on my laptop but it always says its missing a newline. Because i download the game from my synapic manager and it says its missing final newline.
When you are performing time consuming operations in bash like installing new software, is it possible to write text that will appear at the prompt when the operation has finished.
E.g
Imagine running:
apt-get install eclipse-platform
Then it will use quite a while to finish while you see the installation log, meanwhile I want to create new folders (workspaces) which Eclipse later will use.
Is this possible without opening a new terminal (or tab)?
when ever some error happens in the functions, they are not propagated and err_out function is not called.I tried #!/bin/bash -E too; that way when there is an error the script exits but what I need is error to be propagated properly to the handler.
but that changes all. how can I change all files but subdirectorys? I was thinking of something likels -l | grep -v ^d but can't get it to work. I'm still learning about variables and how to use them. thanks in advance for your Patients.
I would like to keep track of not only what bash commands I used and when, but also where they were issued from, i.e. what was the current working directory when I issued "foobar" on a particular day and time. Can we ask bash history to keep track of working directories too? I have tried to get an idea of this reading the enormous "man bash", but I don't seem to have an answer yet either way.