09-13-2010
Cut and WhiteSpace Problem
Hi,
I have a shell script that reads a parameter file to set variables. I have an issue when the parameter I try to read contains whitespace.
e.g
File Contents
Quote:
N|N|N|Fileencode.txt|This is the first one
Code
Quote:
for PROCESS_RECORD in `grep -i "^${PRCSNAME}" ${PARAMETER_OUTBOUND}` ; do
SUBJECT=`echo ${PROCESS_RECORD} | cut -d "|" -f5`
done
The result is SUBJECT is set to
and I want subject set to
I've tried different variations but nothing seems to work.
Can anyone help please
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi all!
Here is my problem :
$ more file
yougli:passwd:123456:3265:Yepa Yepo:/home/yougli:/bin/ksh
As you can see, in the field "information", there are two spaces between "Yepa" and "yepo".
My problem is :
$ PARAM='more file | cut -d":" -f5'
$ echo $PARAM
Yepa Yepo
Now i only... (2 Replies)
Discussion started by: tomapam
2 Replies
2. UNIX for Dummies Questions & Answers
Hello folks,
I have to (e)grep out a certain pattern e.g. <TAG1> from a huge log file which does not have any space as such.
The thing is that once I have 'grep'ed out the <TAG1> from the file I need to extract the content within the tags, i.e,
<TAG1>Data_To_Be_Extracted</TAG1>
The underlined... (9 Replies)
Discussion started by: Rajat
9 Replies
3. Shell Programming and Scripting
Hi,
Say I have this text file <copy.out> that contains a list of files/directories to be copied out to a different location.
$ more copy.out
dir1/file1
dir1/file2
dir1/file3
"dir1/white space"
dir1/file4
If I do the following:
$copy=`more copy.out`
$echo $copy
dir1/file1... (4 Replies)
Discussion started by: 60doses
4 Replies
4. Shell Programming and Scripting
Hi,
sample datas are :
drwxr-xr-x 2 beewin abidev 96 Jun 13 2006 bwin
drwxrwxr-x 2 blsmg01 smg 96 Jun 13 2006 blsmg01
drwxr-xr-x 2 ccmdummy ccm_root 8192 Jun 13 2006 ccmdum
drwxr-xr-x 5 dipayan users 8192 Oct 29 09:05 dip
I want to cut the last field.
I use ls -ll | grep... (7 Replies)
Discussion started by: samir_standing
7 Replies
5. UNIX for Advanced & Expert Users
I have a single string as below:
Rat run after Cat
i.e. there is a single whitespace after Cat.
This causes my file to fail.
Is there a way I can remove any whitespace at the end of any string.
I tried sed 's/ *//g', but it removes all white space and the above string becomes... (10 Replies)
Discussion started by: RubinPat
10 Replies
6. Shell Programming and Scripting
Hey guys iv written a basic function to ask for input location to find then grep a certain string in the file at the location of the find.
For some reason it finds the file with the certain string it however it says directory not found on each string before the whitespace
eg enter location to... (5 Replies)
Discussion started by: musicmancanora4
5 Replies
7. Shell Programming and Scripting
Hi
Following is an example line.
echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:"
I want it's output to be
200
However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies
8. Shell Programming and Scripting
I need to read in a file and output it without the comments or newlines.
The problem is that is not outputting it properly.
STUDENTSDETAILFILE="../data/studentDetails.txt"
for getlines in `sed '/#/d' $STUDENTSDETAILFILE`
do
STUDENTID=`echo $getlines | cut -d: -f1`
... (1 Reply)
Discussion started by: nerdbot
1 Replies
9. Shell Programming and Scripting
Hi, I am facing issue with cut and wc. here is the sample.
the data in file -
tail -1 05_19_BT_TBL_LOAD_20120524064242.bad|cut -c9-58
WatsSaver - AGGREGATED PLAN1581 CALLS FOR 2872.6
tail -1 05_19_BT_TBL_LOAD_20120524064242.bad|cut -c9-58|wc -c
51
tail -1... (12 Replies)
Discussion started by: donadarsh
12 Replies
10. Shell Programming and Scripting
Hi,
I have a file like this -->
Consider z as space
#cat filename
ABC
<!--Nzzzzz-->
<!--RESUMO-->
EFG
XYZ
<!--Nzzzzz-->
<!--RESUMO-->
I need to cut the <!--RESUMO--> part and paste it to the previous line so that the file will look like this-->
ABC
<!--Nzzzzz--><!--RESUMO-->... (4 Replies)
Discussion started by: samsonata
4 Replies
LEARN ABOUT DEBIAN
stg-edit
STG-EDIT(1) StGit Manual STG-EDIT(1)
NAME
stg-edit - edit a patch description or diff
SYNOPSIS
stg edit [options] [<patch>]
DESCRIPTION
Edit the description and author information of the given patch (or the current patch if no patch name was given). With --diff, also edit
the diff.
The editor is invoked with the following contents:
From: A U Thor <author@example.com>
Date: creation date
Patch description
If --diff was specified, the diff appears at the bottom, after a separator:
---
Diff text
Command-line options can be used to modify specific information without invoking the editor. (With the --edit option, the editor is invoked
even if such command-line options are given.)
If the patch diff is edited but does not apply, no changes are made to the patch at all. The edited patch is saved to a file which you can
feed to "stg edit --file", once you have made sure it does apply.
OPTIONS
-d, --diff
Edit the patch diff.
-e, --edit
Invoke interactive editor.
--sign
Add a "Signed-off-by:" to the end of the patch.
--ack
Add an "Acked-by:" line to the end of the patch.
-m MESSAGE, --message MESSAGE
Use MESSAGE instead of invoking the editor.
-f FILE, --file FILE
Use the contents of FILE instead of invoking the editor. (If FILE is "-", write to stdout.)
--save-template FILE
Instead of running the command, just write the message template to FILE, and exit. (If FILE is "-", write to stdout.)
When driving StGit from another program, it is often useful to first call a command with --save-template, then let the user edit the
message, and then call the same command with --file.
--author "NAME <EMAIL>"
Set the author details.
--authname NAME
Set the author name.
--authemail EMAIL
Set the author email.
--authdate DATE
Set the author date.
-O OPTIONS, --diff-opts OPTIONS
Extra options to pass to "git diff".
STGIT
Part of the StGit suite - see linkman:stg[1]
StGit 03/13/2012 STG-EDIT(1)