[Solved] Help with using tr - Removing white spaces
Hi,
I have a file that contains whitespaces with spaces and spaces and tabs on each line and am wanting to remove the whitespaces. My version of sed is one that does not recognize \t etc.
The sed and awk one-liners below that I found via Google both does not work.
Quote:
sed:
sed 's/^[ \t]*//;s/[ \t]*$//'
awk:
awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'
So my next best option is to use tr, am using tr -d '[:space:]' < in > out and while that one works, I am unfortunately losing the line endings.
When I run the tr command
The input below:
Becomes:
Preferably, I want it to be as below:
At the moment since I don't know how to get around this, am using a while read loop that reads each line and running tr -d '[:space:]' on each line. I believe this is a bit of an overkill.
Can anyone advise whether I should be able to get the desired result using tr instead of the while loop?
How would I delete white spaces in a specified file?
Also, I'd like to know what command I would use to take something off a regular expression, and put it onto another.
ie.
.
.
.
expression1 <take_off>
.
.
.
expression2 (put here)
.
.
.
Any help would be great, thanks! (10 Replies)
hi all...
i have the next question:
i have a flat file with a lot of records (lines). Each record has 10 fields, which are separated by pipe (|). My problem is what sometimes, in the first record, there are white spaces (no values, nothing) in the beginning of the record, like this:
ws ws... (2 Replies)
I have a variable that calls in a string from txt file. Problem is the string comes with an abundance of white spaces trailing it. Is there any easy way to trim the tailing white spaces off at the end? Thanks in advance. (9 Replies)
Hi,
Can anybody suggest me how to combine two strings with two or more white spaces and assign it to a variable?
E.g.
first=HAI
second=HELLO
third="$first $second" # appending strings with more than one white spaces
echo $third
this would print
HAI HELLO
Output appears... (2 Replies)
'String' file contains the following contents,
D11, D31, D92, D29, D24,
using ksh, I want to remove all white spaces between characters no matter how long the string is.
Would you please give me some help? (1 Reply)
what my code is doing, it is executing a sql file and the resullset of the query is getting stored in the text file in a fixed format. for that fixed format i have used the following code::
Code:
awk -F":"... (2 Replies)
Hi,
I am having problem in deleting the leading spaces:-
cat x.csv
baseball,NULL,8798765,Most played
baseball,NULL,8928192,Most played
baseball,NULL,5678945,Most played
cricket,NOTNULL,125782,Usually played
cricket,NOTNULL,678921,Usually played
$ nawk 'BEGIN{FS=","}!a... (2 Replies)
Hello All ,
1. I am trying to do a task where I need to remove Blank spaces from my file , I am usingawk '{$1=$1}{print}' file>file1Input :-
;05/12/1990 ;31/03/2014 ;
Output:-
;05/12/1990 ;31/03/2014 ;This command is not removing all spaces from... (6 Replies)
I am trying to remove whitespaces from a file containing sample data as:
457 <EOFD> Mar 1 2007 12:00:00:000AM <EOFD> Mar 31 2007 12:00:00:000AM <EOFD> system <EORD> 458 <EOFD> Mar 1 2007 12:00:00:000AM<EOFD>agf <EOFD> Apr 20 2007 9:10:56:036PM <EOFD> prodiws<EORD> . Basically these... (11 Replies)
Discussion started by: amvip
11 Replies
LEARN ABOUT FREEBSD
mqueuefs
MQUEUEFS(5) BSD File Formats Manual MQUEUEFS(5)NAME
mqueuefs -- POSIX message queue file system
SYNOPSIS
To link into kernel:
options P1003_1B_MQUEUE
To load as a kernel loadable module:
kldload mqueuefs
DESCRIPTION
The mqueuefs module will permit the FreeBSD kernel to support POSIX message queue. The module contains system calls to manipulate POSIX mes-
sage queues. It also contains a file system to implement a view for all message queues of the system. This helps users to keep track of
their message queues and make it more easily usable without having to invent additional tools.
The most common usage is as follows:
mount -t mqueuefs null /mnt/mqueue
where /mnt/mqueue is a mount point.
It is possible to define an entry in /etc/fstab that looks similar to:
null /mnt/mqueue mqueuefs rw 0 0
This will mount mqueuefs at the /mnt/mqueue mount point during system boot. Using /mnt/mqueue as a permanent mount point is not advised as
its intention has always been to be a temporary mount point. See hier(7) for more information on FreeBSD directory layout.
Some common tools can be used on the file system, e.g.: cat(1), chmod(1), chown(8), ls(1), rm(1), etc. To use only the message queue system
calls, it is not necessary for user to mount the file system, just load the module or compile it into the kernel. Manually creating a file,
for example, ``touch /mnt/mqueue/myqueue'', will create a message queue named myqueue in the kernel, default message queue attributes will be
applied to the queue. It is not advised to use this method to create a queue; it is better to use the mq_open(2) system call to create a
queue as it allows the user to specify different attributes.
To see the queue's attributes, just read the file:
cat /mnt/mqueue/myqueue
SEE ALSO mq_open(2), nmount(2), unmount(2), mount(8), umount(8)AUTHORS
This manual page was written by David Xu <davidxu@FreeBSD.org>.
BSD November 30, 2005 BSD