Programming :: Grep Ignoring Spaces Or Tabs?
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
ADVERTISEMENT
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
Jul 2, 2010
I have a lot of files with tabs littered throughout, and I'd like to convert them all into spaces. I know about the expand command, but unfortunately I would have to type out every single file using it. Is there any easier way to do this on Linux?
View 2 Replies
View Related
Feb 26, 2010
How do you convert tabs to spaces?
View 6 Replies
View Related
Jun 12, 2011
Kernel 2.6.21.5, slack 12.0 I have a file beginning with <?xml version=1.0?>. May I replace tabs by spaces in it?
View 6 Replies
View Related
Mar 17, 2010
How to make mcedit not replace tabs with 8 spaces?
View 2 Replies
View Related
Feb 21, 2011
Iam reading a file using C-sh script after manipulating the variables I need to dump into a new file. This in working fine but I couldn't retain the multiple spaces and tabs in a same line. For readability I want to print it back as I read. Now script treating multiple tabs as onl tab or space.
View 3 Replies
View Related
Nov 22, 2010
I need to kind of grep within grep. My input file would be something like:
[Code]....
and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:
[Code]....
View 4 Replies
View Related
Mar 25, 2010
Firefox is sometimes slow opening new tabs/switching between tabs. If I click on the kickoff application launcher button, it takes a few seconds to open, and typing something in the search makes it hang up for about 20 seconds before it does the search. Clicking on an app takes 16 seconds before the menu window closes and the program begins to start. Then it takes another 30sec-1min before the app is usable. smplayer plays video with tearing.
Like right now I tried taking a screenshot, and it tells me
Error launching /usr/share/applications/kde4/ksnapshot.desktop. Either KLauncher is not running anymore, or it failed to start the application.
while the app worked fine.
I also tried running glxgears right now, and it runs but the gears don't move, and terminal states
15 frames in 19.0 seconds = 0.789 FPS
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
after 48 requests (48 known processed) with 15 events remaining.
If I'm on dolphin, and I click a video to start smplayer, it takes about 1 minute for it to start.
Memory is using 1.4GB out of 3.6GB, with 0.08GB/2GB swap
Top shows an average usage of less than 10% average. Xorg is always 25%, kwin is always 10% and then rest of the apps are less than that.
CPU: AMD Athlon(tm) II X4 620 Processor
Integrated VIdeo: HD4200 with fglrx driver
When I ssh into the computer with x tunneling, the programs start up faster than being on the desktop
View 5 Replies
View Related
Nov 4, 2010
I'm trying to write a bash script that has to extract values from a csv file. Problem is there are lines like this:a,b,c,"dd,dd,dd",e,f,gI'm using awk to extract the values but when I try it extract value 4 with awk I get:"ddinstead of:"dd,dd,dd"Does anyone know how to get awk to ignore commas within double quotes?
View 5 Replies
View Related
Apr 8, 2010
i am searching a string(with multiple words) in a file that file contains the string but words are separated with multiple white space.
ex: pattern to be matched "hello how are you" all single white space and file contains " hello how are you" variable white space between words
grep "pattern" file_in_which_to_search i am reading the "pattern" so i cannot modify the "pattern"
so my pattern match does not take place, though i want it to match.
View 3 Replies
View Related
Nov 1, 2010
I've just moved onfrom developing some code on Debian (gcc 4.1) to Ubuntu (gcc4.4) and a warning in my g++ code has appeared. Basically in some serial prot code I get this errorwarning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_resultfrom function
void TxChar(COMPORT *port,unsigned char letter)
{
pthread_mutex_lock( &txmutex );
[code]....
View 7 Replies
View Related
Jan 12, 2011
I need to read a binary file using my C++ application. That binary file may contain arbitary characters and it also contains 0 at some places. I need to read the file without considering null terminating character. (i.e. considering 0 as a normal byte and not as the end of the string)Can some one suggest me a method to read the buffer while ignoring the null terminated character.
View 4 Replies
View Related
Apr 25, 2010
want to set more text files. They have "tab" differently (3, 4, 6 or 5 characters space).I have to use "sed" or "awk" sette them in the same tab (for example five space haracters).
View 14 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
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
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
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
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
Dec 2, 2010
I am trying to read a file character wise and trying to write the same character to another file. In this process, I unable to read and write white spaces successfully to the new file. The script reads the white spaces but while writing the white space is lost. The section of the code, is given below. Please advice how can i read and retain the white space while writing to a new file.
Code:
if [ -s f_test.txt ] && [ -f f_test.txt ]; then
echo "File Exists !!"
while read -n1 char; do
[code]....
View 2 Replies
View Related
Jan 11, 2011
I often get files with many spaces as part of their names. I would like to automatically replace these spaces with underscores, but otherwise not change the file name. Is there a way to do this task with just the bash shell?
View 4 Replies
View Related
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
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