09-23-2008
Triming spaces for any variable
Hi,
I want to trim the spaces on left side of the variable value. For eg: if it is 4 spaces followed by value, All the spaces on the left should be supressed.
Easy but want it quickly.
Regards,
Shiv@jad
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help.
echo $SH_VAR | command_line Syntax.
The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies
2. Shell Programming and Scripting
Hi,
my var is:
PATH_LOG=/opt/WebSphere/CR Comune Roma.log
a filename which contains blank chars.
How can I call it from prompt ?
Ex:
ls $PATH_LOG or
cat $PATH_LOG
tks,
Carmen- (2 Replies)
Discussion started by: Carmen123
2 Replies
3. Shell Programming and Scripting
Hi All,
I have a requirement, in which i have to append some spaces to the variable, and then send it to another function.
I am new to the UNIX shell programming. Ultimately the length of the string should be 40 characters.
exp:
Login = "rallapalli" (length = 10)
i have to append 30 spaces to... (2 Replies)
Discussion started by: rallapalli
2 Replies
4. Shell Programming and Scripting
Hi,
i have to form the header and add fillers(spaces) to it.
I have done something like this. i have added 10 spaces at the end
HDR="AAAABBBBCCNN "
echo $HDR >> file1.dat
but the spaces are not being stored in the file. How to add the spaces. (2 Replies)
Discussion started by: dnat
2 Replies
5. Shell Programming and Scripting
Hello all. I am a newb obviously and a bit stumped on this, so any help gratefully accepted.
The script is extracting metadata from individual mp3 files, then (hopefully will be) sorting them into newly-created subdirectories. I have filtered out the relevant metadata and have the album names... (8 Replies)
Discussion started by: spoovy
8 Replies
6. Shell Programming and Scripting
Hi i have an input " load /appss/asdfas/...
I want to take the string present between first / / i.e appss
Input is "load /appss/asdfas/..."
Expected output is appss
Thanks in advance
Ananth (9 Replies)
Discussion started by: Ananthdoss
9 Replies
7. Shell Programming and Scripting
Gooday
I have an argument string that contains 15 arguments.
The first 14 arguments are easy to handle because they are separated by spaces
ARG14=`echo ${ARGSTRING} | awk '{print $14}'`
The last argument is a text that may be empty or contain spaces. So any ideas on how I get the last... (23 Replies)
Discussion started by: zagga
23 Replies
8. Shell Programming and Scripting
File contains 10 columns,i want trim the 2,4,10 columns using single unix command.
Please suggest me how to do?
Thanks (21 Replies)
Discussion started by: bmk
21 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I'm passing a variable to a scrpit which can be 1 to 3 characters long.
How can I force it to be three character long and add spaces to it?
The passed variable is stored in $1 and I would like to be stored in NewName
I tried without success
NewName=$(printf "%*s 3 $1)
So if... (2 Replies)
Discussion started by: f_o_555
2 Replies
10. UNIX for Beginners Questions & Answers
Hi, I have a big csv file with below data.
file:
La Cage Aux Folles (Widescreen)
Famous Mystics and Psychics
A Passion for Planning Financials Operations Marketing Management and Ethics
Precious Moments Holy Bible New King James Version Precious Angels Edition Blue
Practical Recording... (9 Replies)
Discussion started by: Raghuram717
9 Replies
SDIFF(1) BSD General Commands Manual SDIFF(1)
NAME
sdiff -- side-by-side diff
SYNOPSIS
sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2
DESCRIPTION
sdiff displays two files side by side, with any differences between the two highlighted as follows: new lines are marked with '>'; deleted
lines are marked with '<'; and changed lines are marked with '|'.
sdiff can also be used to interactively merge two files, prompting at each set of differences. See the -o option for an explanation.
The options are:
-l Only print the left column for identical lines.
-o outfile
Interactively merge file1 and file2 into outfile. In this mode, the user is prompted for each set of differences. See EDITOR and
VISUAL, below, for details of which editor, if any, is invoked.
The commands are as follows:
l Choose left set of diffs.
r Choose right set of diffs.
s Silent mode - identical lines are not printed.
v Verbose mode - identical lines are printed.
e Start editing an empty file, which will be merged into outfile upon exiting the editor.
e l Start editing file with left set of diffs.
e r Start editing file with right set of diffs.
e b Start editing file with both sets of diffs.
q Quit sdiff.
-s Skip identical lines.
-w width
Print a maximum of width characters on each line. The default is 130 characters.
Options passed to diff(1) are:
-a Treat file1 and file2 as text files.
-b Ignore trailing blank spaces.
-d Minimize diff size.
-I regexp
Ignore line changes matching regexp. All lines in the change must match regexp for the change to be ignored.
-i Do a case-insensitive comparison.
-t Expand tabs to spaces.
-W Ignore all spaces (the -w flag is passed to diff(1)).
ENVIRONMENT
EDITOR, VISUAL
Specifies an editor to use with the -o option. If both EDITOR and VISUAL are set, VISUAL takes precedence. If neither EDITOR nor
VISUAL are set, the default is vi(1).
TMPDIR Specifies a directory for temporary files to be created. The default is /tmp.
SEE ALSO
diff(1), diff3(1), vi(1), re_format(7)
AUTHORS
sdiff was written from scratch for the public domain by Ray Lai <ray@cyth.net>.
CAVEATS
Although undocumented, sdiff supports all options supported by GNU sdiff. Some options require GNU diff.
Tabs are treated as anywhere from one to eight characters wide, depending on the current column. Terminals that treat tabs as eight charac-
ters wide will look best.
BUGS
sdiff may not work with binary data.
BSD
February 21, 2007 BSD