Programming :: BASH Script: Spaces Are Getting Converted To TAB Character?
Dec 23, 2010
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:
$ORACLE_HOME/bin/sqlplus -s ${CONNECT_STRING} >${out_file} <<!!
.. sql query..
!!
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)
View 3 Replies
ADVERTISEMENT
Mar 20, 2010
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.
View 10 Replies
View Related
Nov 30, 2010
I have read where C is first converted to Assembly before its final compilation to binary. Is there a way to do this with Bash commands? I would like the understanding that Assembly allows to Bash somehow.
View 14 Replies
View Related
Jul 24, 2010
I have a laptop that I am in through SSH. The laptop does not have an Xwindow system so I am using the program fbi to open an image on my laptop screen from my SSH connection:
fbi -T 8 picture.jpg #this opens the image on the laptops tty8 terminal
I've found that making a for loop does not work with files that contain a space in the name. Something to due with a bug that they call a "feature" that stops the first variable at the first whitespace.
Using a "while" loop is not exactly what i require either seeing as I want to be able to view each image in the directory on screen and tag it accordingly, before it jumps off to the next image, and I'm not sure how to add a pause to a while loop.
How do I make a Bash script and loop Variables handle files like "files that contain spaces.jpg"
View 5 Replies
View Related
Jan 15, 2010
I have over 50 files names with spaces in them.
I'm trying to use a for loop as such:
However, when I print the $filename in the script, the script prints out parts of the filename because of the spaces in the file name.
For example, say the file name was Star Quest.php
When the script executes one $filename would be Star and another Quest.php.
How could I account for this? Something like $'filename'
View 13 Replies
View Related
Apr 1, 2011
*I'm using Ubuntu 10.10
My issue is I can't handle the files with spaces in their name, I've donde the below script to print each file found inside folder and subbfolders with "find".
I would like to "ls" to each file found with its complete path and with its basename too.
Code:
files=$(find . -type f)
for each in "$files"
do
ls -l "$each" # 1rst option I've tried to list with full path
ls -l "$(/bin/echo "$each")" # 2nd option I've tried to list with full path
ls -l "$(/bin/echo $(basename "$each"))" # 1nd option I've tried to list with it basename
[Code].....
How can I list "ls -l" in both cases (with full path and with basename) when there are files with spaces in their name?
View 6 Replies
View Related
Feb 15, 2010
having bit of a trouble with path expansion of strings that contain some whitespace and wildcards First my script sources a configuration file that contains array assignments
Code:
...
BACKUP_TARGET_FILES[2]=/boot/config-* # no problems
BACKUP_TARGET_FILES[3]="/root/random dir with space/file*" # this is the problem
...
then later in the script I want to expand BACKUP_TARGET_FILES elements as below
Code:
IFS_DEFAULT="$IFS"
shopt -s nullglob
shopt -s dotglob
IFS=
[code]....
this code seems to work but I'm not quite satisfied with it. I'd like to get rid those IFS changes, but haven't found out a solution as of yet. Problem with default IFS seems to be that with it neither $pattern or "$pattern" work; it either interprets pattern as multiple words (because of spaces) and so expands to wrong paths or it ignores * because it's within quotes.
View 11 Replies
View Related
Jan 25, 2011
Have worked with Linux at home for some time and have wrote the below script.
This script is run when a .torrent file finishes downloading and extracts any .rar files into an extracted directory.
However there are 2 thing that i cannot for the life of me get working.
These are:
1. I need the script to check a txt file to see if the file has been extracted previously.
2. The script does not work with any paths that contain spaces.
Code:
View 11 Replies
View Related
Aug 11, 2009
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?
View 13 Replies
View Related
Sep 14, 2010
I am reading the output of /proc/acpi/thermal_zone/ATF0/temperature in a program to read my CPU temp. I am using cat like the following:
Code:
#cat /proc/acpi/thermal_zone/ATF0/temperature
temperature: 49 C
I basically want to get rid of the spaces in between temperature and the actual temperature. Is there a command I can pipe the cat output to, to remove the spaces. I have seen suggestions for sed, or tr, but for some reason I cannot get them to work properly.
View 14 Replies
View Related
Jun 25, 2015
I am trying to create scripts to move files over from one directory to an ftp server and there is this one file with spaces that bash is see each word as being a file, here is the variable i am trying to use:
Code: Select allLOCL = '/mnt/cifs/"File name with spaces"/'
cd $LOCL
ls -l
View 3 Replies
View Related
Mar 27, 2010
1.What character instructd the shell to interpret a special character as an ordinary character?
2.What directory contains some of the utilities available on the system in the form of binary files?
3. What command is used to search the location of a utility?
4. What command is used to instruct the editor to write the file and quit the editor?
5. What key quits the more utility and displays the shell prompt?
6. What command starts a child shell as the super user, taking on root's identity and environment?
7. Which wildcard characters can be used for searching all the files in the system that start with "A"?
8. The user name or login name of the super user is????
[Code]....
View 10 Replies
View Related
Jun 8, 2011
I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't recognize the file or directory. What can I do about this? Is there any way to use the unicode character for a space?
View 5 Replies
View Related
Mar 25, 2011
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.
View 4 Replies
View Related
Apr 30, 2011
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.
View 7 Replies
View Related
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.
View 4 Replies
View Related
Jan 26, 2010
Is it possible, in Linux, to rename a file from something without spaces to something containing spaces? I know I can create directories and files with spaces by doing:
mkdir "new dir" and:
touch "new file.txt"
I want to rename files from:
imgp0882.jpg to something like:
20091231 1243 some topic.jpg
And how would it look in a shell script that uses parameters like:
for i in *.jpg do
rename "$i" "$somepath/$mydate $mytime $mytopic$extension"
?
I'm new to Linux (using PCLinuxOS 2009.2), coming from Windows, and I've written myself a little shell script to download files from my camera and then automatically rename them according to a date-and-topic pattern. As you can guess by now, I'm stuck on the bit about renaming. If you want to see my script, here's a copy. I'm not using jhead for this renaming because that only works with JPEG files but I want a single solution for any media format including videos.
View 2 Replies
View Related
Aug 9, 2010
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 ?
View 3 Replies
View Related
Jul 9, 2010
I am unable to write a simple Makefile. Though I know the concept am facing this error:
Makefile:2: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
Should I give a tab or spaces not able to continue.
View 5 Replies
View Related
Oct 8, 2010
I have been trying to code a program in C++ that must check for the correct syntax in order to operate. It must find ", " within the string, but I don't know why the compiler won't recognizes spaces.
Code:
#include <iostream>
#include <stdio.h>
#include <string>
[Code]....
So the user must input "<name>, <interest>" with the ", " (comma and space) but even if you respect the syntax the compiler will skip to the else condition. I don't know why, but if I put any other condition like ",s" it will work, but not with spaces.
View 7 Replies
View Related
Nov 27, 2010
I have a file of the type:
a = b
where a is any string and b is an integer The 'a' string doesn't have any spaces in it.
Everything was running fine till I was searching for 'a' and finding value 'b' by expression
Code:
string="$a"
egrep -i -m1 "^[[:space:]]$string[[:space:]]*=" | awk -F'=' 'gsub(/^[[:space:]]+/,"",$2)gsub(/[[:space:]]+$/,"",$2){print $2}'
I recently ran into a situation where in the string 'a' had symbols like $, & in it. Though I haven't checked it for & but $ is definitely breaking my code
Any way to egrep for string with $ ??
One way I though was to replace every occurence of $ with $ in my search expression but that would involve an extra processing each time
View 10 Replies
View Related
Oct 1, 2010
In the code below:
Code:
The output is:
Code:
Looks like the "," operator in the print inside the loop is adding a space for its own.
I want to print the sequence WITHOUT spaces. Something like this:
Code:
But I couldn't figure out how to do this.....
How to print a sequence, inside a loop, without that space ?
View 14 Replies
View Related
Apr 14, 2011
I've searched the forums and the google looking for a means to do this and haven't found anything I can use. I have a large file that looks like this:
Code:
18000034161828M850
18000034172676M850
98 093095
[code]...
I need to add spaces at the end of each line to ensure that every line has 80 chars before the carriage return. I was thinking something like this, but it doesn't do the right thing:
Code:
cat filename | sed -e 's/$/(bunch of spaces)/' | cut -c1-80 > filename2
I'm on fedora, so I can use awk, sed, bash, ksh, etc.
View 14 Replies
View Related
Feb 24, 2010
Which do you prefer and why? Also, I remember someone telling me once that while using space indentation use either 4 spaces or 2 spaces. Don't use 3 spaces. Anyone know why they would say not to use 3 spaces?
View 14 Replies
View Related
Nov 22, 2010
I'm writing something which takes user input (which may or may not contain spaces...) and then runs a command on a remote system via ssh. However the remote command does not work. I can't print the exact code so I'll just provide an equivelenat problem. This needs to work with filenames which do and do not contain spaces.
Code:
FILES=`ls`
echo "Specify a file"
echo "$FILES"
echo -n "File name: "
read $FILES
ssh root@127.0.0.1 "ls $FILES"
View 5 Replies
View Related
Jun 4, 2010
This _almost_ works. I just can't quite get it to honor the spaces.
Code:
#!/bin/bash
profiles=(
PROFILE_ONE
)
PROFILE_ONE=(setting1 "setting number 2")
[code].....
View 9 Replies
View Related
Jun 29, 2010
I writing a script to go through multiple reports. I want to grep daemon.debug @10.10.10.10 on all reports to make sure it is pointing to the right IP address. the problems is the space between debug and @10 are different on all the reports, some have one space some have two and some have tabs how do I ignore the tabs or spaces and grep daemon.debug @10.10.10.10
daemon.debug /var/log/ftp rotate size 20m files 4 compress
daemon.debug @10.10.10.10
authpriv.* /var/log/secure rotate size 20m files 4 compress
authpriv.* @10.10.10.10
View 6 Replies
View Related
Sep 16, 2010
the preceding and trailing spaces around the commas in my CSV without destroying my address field. I'm new to regex and sed so this is probably easy but I just can't do it without destroying the Address section. I'm using vanilla Linux and sed 4.1.3I'm willing to use any regex or even awk if needed.
Example:
I need this
randall , dean, 11111 , 1309 Hillside Ave., Warsaw, VA , 23591
[code]....
View 11 Replies
View Related
Apr 13, 2011
I have a fresh dedicated server that im currently configuring and needed a little help if I may ask.The problem is that i'm having a file naming issue. for example from the web I can access any file that does not have spaces of any type. ex/music/musicfile.mp3this works fine and my php script can locate itBut the problem is when I try to access a file that has spaces.ex/music/The Eagles - Hotel California.mp3my php script can't seem to locate any files like this with spaces but doesn't have a problem locating the files with no spaces.
I also took a look at the directory within shell. I did notice that files that have spaces are showing up in this formatt in shell.#/home/~username/public_html/music/The Eagles - Hotel California.mp3In shell , i'm assuming that unix/linux maybe adds a backslash before spaces. But when I FTP to this same directoy, the filename look normal and at windows standard. how could I correctly access these types of files within my php scrits? or would I need to have all uploaded files renamed so that spaces are replaced with underscores maybe?
View 4 Replies
View Related
Mar 3, 2011
I'm trying to insert a line using sed that has leading spaces before the text. Sed seems to be just dropping the spaces and only inserting the text. Any ideas what I'm missing?
Code:
NAM=rb134
sed -i.bak -e "$i
host ${NAM} {" /etc/crap
Instead of inserting a line with 8 leading spaces inserts it with "host" at the beginning of the line. I tried
Code:
NAM=rb134
sed -i.bak -e "$i
^ host ${NAM} {" /etc/crap
but it put the "^" at the begging of the line.
View 6 Replies
View Related