Hi all ,
I have a requirement where I have a file. Contents of the file are :
#comments
VAR="abg"
RES=123
#comments
IC6790ABG="https://www.abc.com"
IC5678-vg="https://www.bhy.com"
IC-gy_567:78="https://www.gyt.com"
#comments
The variable names can not have characters like - , : so
in this file I have to find words starting with IC and replace characters like - ,:
I want to change only the variable name , not the whole line.
I have used SED command
sed -i '/^IC/s/[^0-9 a-z A-Z _]*//g' file
when I am using this command , it is replacing the whole line
output becomes :
#comments
VAR="abg"
RES=123
#comments
IC6790ABGhttpswwwabccom
IC5678vghttpswwwbhycom
ICgy56778httpswwwgytcom
#comments
But I want the output like this :
#comments
VAR="abg"
RES=123
#comments
IC6790ABG="https://www.abc.com"
IC5678vg="https://www.bhy.com"
ICgy_56778="https://www.gyt.com"
#comments
How can I get the desired output , thanks for your help in advance .
Hi All,
How can I replace the particular word using sed or awk
Code:
$ BUGZILLAURL="https://mylocalserver.com/bugzilla"
$ PROJECTNAME="mybugs"
$ echo "$BUGZILLAURL/$PROJECTNAME"
https://mylocalserver.com/bugzilla/mybugs
There is a urlbase line in data/params file which has an empty variable, pls see 2nd line from below command's output.
Code:
$ grep -i "urlbase" data/params
'docs_urlbase' => 'docs/%lang%/html/',
'urlbase' => '',
'webdotbase' => 'http://www.research.att.com/~north/cgi-bin/webdot.cgi/%urlbase%',
Or search only for that line which I wanted to be as 'urlbase' => 'https://mylocalserver.com/bugzilla/mybugs',
Code:
$ grep -i "'urlbase'" data/params
'urlbase' => '',
So expecting your kind help to replace '' word with 'https://mylocalserver.com/bugzilla/mybugs' using sed or awk.
Thanks.
Hello,
They gave me this:
Code:
#!/bin/bash
# Write error message on stderr and die
function die() {
echo "$@" >&2
exit 1
}
# Load var from properties files
function load() {
for propertie in "$@" ; do
[[ -f "${propertie}" ]] || die "load() : \"${propertie}\" don't exist !"
while read ; do
echo "${REPLY%=*}"
echo "${REPLY#*=}"
[[ -n "${REPLY%%=*}" && -z "${REPLY#*=}" ]] || die "load() : Variable \"${REPLY%%=*}\" is empty!"
eval "${REPLY%%=*}"=\'"${REPLY#*=}"\'
done < "${propertie}"
done
}
load "manage_srcds.conf"
echo "SRCDS_TICKRATE=$SRCDS_TICKRATE"
echo "SRCDS_SCREEN=$SRCDS_SCREEN"
echo "SRCDS_SRCDS_GAME_NAME=$SRCDS_GAME_NAME"
echo "SRCDS_MAXPLAYERS=$SRCDS_MAXPLAYERS"
but, return:
Quote:
###################################################
###################################################
load() : Variable "###################################################" is empty!
cat manage_srcds.conf
I just wish that there was no empty variable excluding those who do not have integer.
Best regards,
i am getting the folowing error while running the tcl script:-
can't read "source1": no such variable
while executing
"set source1"
(file "gray.tcl" line 109)
abhishek@ubuntu:~/Ns2$ ns gray.tcl
num_nodes is set 9
INITIALIZE THE LIST xListHead
can't read "source=1": no such variable
while executing
"set source=1"
(file "gray.tcl" line 109)
I am trying to process some .csv files with Linux as follows:
Some fields have data with newline characters embedded, like so:
"Bob Smith
531 Pennsylvania Avenue
Washington, DC"
(I verified the existence of the " via Wordpad. The file is too large to easily edit in Wordpad to get all the data for each row on a single line).
what linux command would I use on the files to get the data in each cell on one line?
I have tried:
1. awk -v RS="" '{gsub (/\n/,"")}1' file > newfile
but the cell data was still being read in as if "531 Pennsylvania Avenue" was a brand new row in the CSV file.
2. Command 1 followed by awk -v RS="" '{gsub (/\r/,"")}1' newfile > finalFile
but that resulted in all of the data in the file being put onto a single line.
3. awk -v RS="" '{gsub (/\r\n/,"")}1' file > newFile
But that result was the same as attempt number 2.
How can I preprocess the file so that:
"Bob Smith
531 Pennsylvania Avenue
Washington, DC"
is read as a single field on a single line as part of the row it should be associated with, like
"Bob Smith 531 Pennsylvania Avenue Washington, DC"
I want to And search grep shell
but It's hard to grep variable
---------------------------------------------------------------
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Ussage: phone searchfor [...searchfor]"
echo "(You didn't tell me what you want to search for )"
else
pass=0
find=""
for idx in $*
do
if [ -n "$idx" ]
then
if [ $pass -eq 0 ]
then
find=$(egrep "$idx" mydata)
pass=1
else
find=$("$find" | grep "$idx")
echo $find
fi
fi
done
if [ -z "$find" ]
then
echo "There is no such thing"
else
echo $find | awk -f display.awk
fi
fi
-----------------------------------------------------
there is one error : command not found
in find=$("$find" | grep "$idx")
how can I grep variable and store it into variable?
hello,
i am trying to make a table from some files. i used this to record how much "RD_" field i have in my file.
Quote:
grep -o 'RD_' $f|grep -c 'RD_'
forexample i got 5 "RD_" fields now i want to print 5 number of fields from another file starting from 2nd field. i did it mannully like
Quote:
awk 'NR==1{print"{"$2","$3","$4","$5","$6","0.0000",""0.0000""}"","}' $file
i want to make it work together and a bit auto matic like
PHP Code:
awk 'NR==1{print"{"$2"to "$5"," apend zeros to make it total 7 fields"}"","}' $file
your coments would be apreciated
thanks alot
I made the mistake of adding an xterm invocation to my ".bashrc" file. My intent was to simply execute an xterm upon initial login to the KDE environment on Debian Wheezy (though the distro probably would have made no difference). What happened is that with each invocation of "xterm", the new xterm would again invoke an "xterm" via the ".bashrc" file. Duh, infinite recursion of xterms upon login. Is there a simple way to invoke an xterm at login that doesn't itself lookup the ".bashrc" file? By the time someone answers this, I will probably find and answer somewhere in the bash/xterm man pages, but thought I'd throw it out there. Really felt stupid after having realized my mistake. Had to login to recovery command line mode and replace the ".bashrc" file with "/etc/skel/.bashrc". Cheerio
Hey,
please find attached the code
I got this error :
can't read "mac_(0)": no such variable
while executing
"subst $[subst $var]"
(procedure "_o112" line 5)
(SplitObject set line 5)
invoked from within
"$iface2 set mac_(0)"
invoked from within
"set tmp2 [$iface2 set mac_(0)] "
(file "umts.tcl" line 319)
can anyone help to solve the error??
Hi, I am using a XML file in server location which contains some attributes and value.I just want to replace the attribute value inside the tag keeping the complete line and xml file intact. I am looking for Regular expression which can search for attribute name and replace the attribute value with the provided one. Please find below property details.
<server>
<mbean code="com.xyz.domain.wsmq.WSMQConnectionFactory"
name="xyz.qps:service=MQQueueConnectionFactory">
<attribute name="QueueManagerName">QMSTR01</attribute>
<attribute name="HostName">xx.yy.zz.ww</attribute>
<attribute name="Channel">channel01</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
</server>
Hello,
I am trying to install OCI8. I'm pretty sure the last thing I need to do is run the "./configure" command, but no matter where I try to run it, it gives me back a "file not found" or "command not found" error. I have tried this on CentOS and Fedora and always install PHP with yum. I have done many GUI searches looking through the file system for "php" and have tried to run ./configure in every php folder I can find but the command never runs. Any suggestions are very much appreciated. Thanks so much!
-Matt
P.S. Do I even need to do this if I already edited the "php.ini" file and installed OCI8 with PECL? Thanks!