General :: Printf White Space - Words Splitting?
Jun 15, 2010
I am having trouble keeping the name together and the phone number together, I think due to the white space. I have tried "" and '' it doesn't seem to matter. So it may be my syntax? and does it matter how long the first and last names are.
me$ echo 'fstname lstname' '123 123-1234' | ./myscript
#myscript
read a b
printf "%-15s %20s
" $a $b >> my_phone_numbers
OUTPUT
fstnamelstname
123123-1234
insted of
fstname lstname
123 123-1234
I know its not an elegant script but I am still learning how some commands work.
View 2 Replies
ADVERTISEMENT
May 26, 2011
I want to search lines with these stings with one or more spaces..
e.g
Code:
a b
a b
a b
a b
How will I achieve this by egrep ?
View 14 Replies
View Related
Oct 6, 2010
I have a text file that gets produced at the end of the script being run.
For this example the text file will produce the following:
Quote:
THE COW
THE DOG
THE CAT
THE HORSE
In the script I am using either echo or printf to print on the screen each line and then it is doing a test and produces a good or bad result.
Another example:
Quote:
THE COW -- IS HOME
THE DOG -- IS HOME
Each whitespace between the -- are 5 spaces. How can I get them to be in-line and formatted when it gets to more words, when THE HORSE arrives.
Example:
Quote:
THE COW -- IS HOME
THE DOG -- IS HOME
THE CAT -- IS HOME
THE HORSE -- IS HOME <-- This has only 3 whitespaces but is still formatted.
View 8 Replies
View Related
May 18, 2011
I have some data whose no certain pattern. Below is as an example.
20110101 1+1-0 1-1 1+1-2 8- 5 3 0 3 4 5 3 7 4
20110102 1+2-0+1-1-1+2-1+ 9 5 6 2 3 3 5 6 5 4
20110103 1-1-0+1 1 2 2 2+10 3 3 2 4 4 7 7 9 5
20110104 1+3-1 1 1+2-2-1-11+ 5 12 4 4 5 6 6 3 6
20110105 0 0 0 1-1-1-1+1 4+ 0 0 0 3 3 3 5 4 2
20110106 1+0+0 0+0+1 2 4+10- 5 2 0 2 2 4 7 32 7
I want to remove space, + and - mark so that I can get the below such data :
20110101 1 1 0 1 1 1 1 2 8 5 3 0 3 4 5 3 7 4
20110102 1 2 0 1 1 1 2 1 9 5 6 2 3 3 5 6 5 4
20110103 1 1 0 1 1 2 2 2 10 3 3 2 4 4 7 7 9 5
20110104 1 3 1 1 1 2 2 1 11 5 12 4 4 5 6 6 3 6
20110105 0 0 0 1 1 1 1 1 4 0 0 0 3 3 3 5 4 2
20110106 1 0 0 0 0 1 2 4 10 5 2 0 2 2 4 7 32 7
Is it possible by using awk?
View 7 Replies
View Related
Feb 12, 2011
I have successfully gotten my Canon MX300 Printer to work with CUPS. The printer works great, but for some reason it prints out white lines incredibly slow. The printer acts as if it is printing out actual text, e.g. if I have half a page of empty space, it prints it line by line for some reason... Anyone know what may cause this? I know that CUPS is not ideal with all printers, but it did not do this at first actually.
View 2 Replies
View Related
Dec 16, 2010
Some context: I'm calling some functions from within a C program and want to measure how long they take to execute. I've done this successfully, calling printf to print the results to the screen. This is reasonably fast. Ideally I'd like these to be dumped to a file, but fprintf presumably has some overhead since it writes to disk? Unless the data is buffered by the kernel and flushed later? What kind of delay can I expect before fprintf returns?
If I redirect the stdout to a file when I instantiate the binary as a process, will calls to printf also experience any overhead from redirection to a file? My aim here is to capture all data in a file, with the minimal amount of coding and effort, but with minimal impact in terms of time overheads for printf calls.
View 10 Replies
View Related
May 7, 2010
I scanned a document with xsane and saved it as a pdf, the pdf shows up great but there is extra white space at the bottom of the document. how do i get rid of the white space and make the document the actual real legal size?
View 2 Replies
View Related
May 29, 2010
how to split two files like
big.zip.1
big.zip.2
then, my second is how to merge them like windows
in windows, i can use copy /b
in linux,
cat big.zip.1 > big.zip
cat big.zip.2 >> big.zip
View 1 Replies
View Related
Jan 4, 2010
Logical Memory Space of 4GB is divided in to 3GB User Space and 1GB Kernel Space. Always. Correct?
1. How can we change it? (just changing value of PAGE_OFFSET is okay?)
2. If system have only 256MB of memory (embedded system) and suppose Kernel Modules eat away all the memory during boot. User space will be left will no memory. Is this case possible?
View 2 Replies
View Related
Dec 26, 2010
I have a folder with 15000+ images! How to (using bash) mv the files to sub-folders a/ b/ c/ d/ e/ f/ g/ h/ i/ j/?
View 6 Replies
View Related
Apr 27, 2010
I need files to be <= 5GB to put on S3. Right now I have an ugly tar / gzip / cut before upload, then cat / zcat / tar on download, but it's really ugly - and nearly every archiver should support archive splitting right? What's the best way?
View 2 Replies
View Related
Apr 21, 2010
What's the command to open multiple files in Emacs vertically/horizontally splitting window.
View 4 Replies
View Related
Sep 7, 2010
I am facing a problem while splitting a text file, I need to split a file into some parts and each split file should have 2000 lines, when I do it through "split" command the mother file is kept intact but as per my requirement I need to cut mother file into some parts thus it should not be kept intact.
Example:
file size
motherfile.txt 5000 lines.
after split
motherfile.txt 2000 lines.
childfile1.txt 2000 lines.
childfile2.txt 1000 lines.
View 7 Replies
View Related
Sep 21, 2009
I have a utility that works with files. The utility is crashing at after about 120 files. The input to the utility is a file containing a filelist. I want to cut the file with the file names in it to seperate files containing about one hundred or so. My thought was to determine the number of lines/100 and then use head and delete to create temporary files to run the utility multiple times to prevent the crash. When I tried to create a variable using the wc -l command the output gives me the number of total lines but it also includes the filename of the input file. (873 Filename.txt) I can not figure out how to remove the Filename.txt from the variable.
View 2 Replies
View Related
May 19, 2010
I am currently trying to copy a directory of roughly 400GBs to dvd, have gotten myself stuck. I tried to tar and then split; however, I don't have enough room on my hard-drive to make a compressed tar and split it up and then burn to disk, so I need a way to tar the and compress the directory, split it, and burn to disk every 4.3GBs.
I went ahead and installed DAR as an alternative, as I hear it is designed for this type of task, but I can't figure out which way is heads or tails.
my OS is the newest version of ubuntu 10.
View 5 Replies
View Related
May 16, 2011
I would like to split my display in two, so they would behave like two physical monitors, i.e. it would be for example like to connecting two 960x1080 monitors through physical ports. Is something like this possible? The problem is i would like to run two fullscreen applications on second monitor. Is that even possible? I prefer Windows 7/vista but I welcome Linux solution as well
View 1 Replies
View Related
Oct 10, 2010
here is what is in my file:
[code]...
i have xterminus installed. i also have a white block over the first letter in my username and when i begin typing, the 'block-type cursor' just leaves full white spaces behind and i cannot read my text at all. even when i delete back over the white spaces, they stay whited out.
View 4 Replies
View Related
Apr 5, 2011
I installed compiz on squeeze. I followed the steps on [url] , everything seems fine except my gnome-terminal shows me a white-in-white screen, seems like both the background and foreground are white, I tried to change the gnome-terminal profile, it doesn't work, after I disable compiz, gnome-terminal back to normal. I tried to install xterm, it can work, but it not easy to use for me, I still want to use gnome-terminal,
My laptop is lenovo Thinkpad T400. 01:00.0 VGA compatible controller: ATI Technologies Inc Mobility Radeon HD 3400 Series
View 1 Replies
View Related
May 23, 2010
Can "locate" or "updatedb" be set to print file names with white space properly escaped? For example, I want it to print, "/home/USER/My Files" and not, "/home/USER/My Files". I've googled around, read the man pages, checked the forum, and I'm still stuck.
View 2 Replies
View Related
Sep 1, 2011
I'm trying to update Kubuntu 11.04 here is my error: p, li {white-space: pre-wrap;} E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. here is what i have tried to fix it:
[Code]....
View 2 Replies
View Related
Dec 21, 2010
I need to grep a dictionary file.Only the words that contain 2 or more z's and only 1 b needs to be listed.
View 1 Replies
View Related
Mar 24, 2010
I am trying to use bash 'printf' to format an environment variable.Doing this I get on the screen just the format I need (underscores mean blank spaces):prompt> printf "%10s" "1.23"________1.23Unfortunately, when this is assigned to a variable, the format disappears:prompt> X=`printf "%10s" "1.23"`prompt> echo $X1.23Does anyone know what can be done in this case to get a proper format?Why does not 'printf' respect the left blank spaces when assigning values to a variable?
View 3 Replies
View Related
May 10, 2011
Id like to share with you a strange behavior I�ve been seen with the printf C language function running in Fedora.The code opens a file as showed:descString = fopen( strcat( stringName, txt), a+);There are also some printf functions in the code.However, instead of the printf functions to print their content at the screen, theyve been printing them in the file with the descString file descriptor.Have you ever seen something like that?To print something to the file I use the fprintf function. I didn't make a mistake to confuse printf with fprintf. I'm sure.
View 2 Replies
View Related
Mar 8, 2010
I exported a spreadsheet file into cvs format.
The cvs file is formatted this way
field1,field2,field3,..etc
I want it to be in a Quote delimited format like so
"field1","field2","field3",..etc
View 2 Replies
View Related
Feb 15, 2010
How can I display the no. of lines, words and characters for each file in current directory and in sub directory.
wc . * shows errornous result as there are some executable files in that directory.
View 2 Replies
View Related
Apr 23, 2010
I am looking for this `struct messages_sdd_t` and I need to search through a lot of *.c files to find it.However, I can't seen to find a match as I want to exclude all the words 'struct' and 'messages_sdd_t'. As I want to search on this only 'struct messages_sdd_t' The reason for this is, as struct is used many times and I keep getting pages or search results.The directory I am searching in, has another directories so it will have to search recursively.I have been doing this without success:Code: find . -type f -name '*.c' | xargs grep 'struct messages_sdd_t'and thisCode: find . -type f -name '*.c' | xargs egrep -w 'struct|messages_sdd_t'
View 3 Replies
View Related
Dec 2, 2010
15 for(i = 0; i < N; i++) I want to replace "i" with "test" in the line above,whose line number is 15. When I tried this command :15s/i/test/ Line 15 turned to be this: for(test = 0; i < N; i++) It only replace the first "i",but I want to change all "i" in line 15.
View 3 Replies
View Related
Sep 9, 2010
I want to grep any line with "john" or "jack". How to do that? I tried
grep john | grep jack
but it didn't work
View 2 Replies
View Related
Feb 2, 2010
For eg: $NUMBEROFPASSES=6.19 to round up I use NUMBEROFPASSES=$(printf %.0f $NUMBEROFPASSES) What I need to do is round up from eg: 6.10 to be 7 and if lower than 6.10 round down to 6
View 5 Replies
View Related
Jun 7, 2010
misunderstood structure definition at the beginning
View 3 Replies
View Related