Now I want to erase the data from computername2 because I only want to see the last output from every computernameX.
So before the login script output's the "Computername2|data1|data2|data3" line I want it to erase it's previous output. When I use
the file2.csv is empty. When I only use grep (without -v) the file2.csv is similar to file.csv. When I manually edit the file.csv file en hit enter after all the lines and save the file then it works fine. So somehow the grep command "sees" only one line. Now I searched the web for all day now but I can't figure out what to do. I think it has something to do with new lines or carriage return.
So what to do? Maybe use another command then grep? Or change the way of output in the login script?
Last edited by mattiasvdm; 11-28-2012 at 05:12 AM..
Reason: added code tag's
Missing right curly or square bracket at -e line 1, at end of line
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
So I added the right curly bracket at the end like this:
So then I get this error:
Can't call method "_END_" without a package or object reference at -e line 1, <> line 1.
I must say I have no experience with perl and I'm pretty new to unix as well. Still I wonder if there is a way to change the way of output of the initial data in the first place. Since the grep command actually works fine when I manually hit enter after all the lines.
Awk doesn't seem to work either. If I use:
File2 is the same as file1. If I output to the terminal window it output's everything in one single line. So again that's where the problem seems to be.
---------- Post updated 29-11-12 at 12:00 PM ---------- Previous update was 28-11-12 at 04:02 PM ----------
SOLVED!
The problem was in the first output. Every line ended with a Carriage Return (CR). That's why the grep command "sees" only one line of data. For the grep command to work every line has to end with a Carriage Return AND a Line Feed (CR+LF).
So what I did was change the way of output of the initial data:
As you can see I added the \r in the end. By doing this you get the CR and LF at the end of every line.
Hi.
I have a command line that will generate exif data from .jpg files...
So to get the Camera Model I use:
find -iname "*.jpg" -print0 | xargs -0 exiftool -a | grep "Camera Model"
But I want the file name AND the camera model... How to I get the grep to give me TWO bits of information from... (2 Replies)
I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore.
Here is what 's happening:
* I wanted to remove lines containing digits so I used this... (25 Replies)
Hi guys -
I am trying to have a certain file display information horizontally divided by a pipe.
for example
file name: foo.dat has information like this:
name1
name2
name3
namenamename4
namene5
I would like it to display like this:
name1|name2|name3|namenamename4|namene5
... (6 Replies)
currently I have process from a raw file to this stage
ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID")
ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID")
ALTER TABLE... (10 Replies)
hi
i am running grep -c on a bunch of files some of which may be non existent. The output i get is in the same order as the files grep checks and this is what i want as i need to copy the output to a spreadsheet. However when i tried to pipe the output to sed to strip away the filenames and just... (5 Replies)
From below mentioned line,i have to display output as last word only ie:arch_1_105366_720809746.dbf
-rw-r----- 1 oracle dba 98887680 02 Mar 12:01 arch_1_105366_720809746.dbf
Please .. (5 Replies)
Hello,
I have a list of stings that I'm using with grep to determine which files contain the strings. Here's what I have now:
list of strings in a file (list.txt):
/directory/direc tory/file.jsp
/dire ctory/directory/direct ory/file.jsp
grep I'm doing to find files that contain the... (4 Replies)
Hi All,
I am getting the output for the following command when i run it on the unix console.
---------------------------
grep `whoami` /etc/passwd | awk '{print ($1);}' | cut -d ":" -f3
----------------------------
But i made it into a script and tried to print the variable, its... (5 Replies)
How can I perform a grep and it will give me a contain word (maintenance) instead of a string or the whole line of info.
grep with exclusive output?
or is there a CONTAIN with IF statement ?
I have a file call yast2_vhost.conf and it contain multiple entries call
maintenance.html... (2 Replies)
hi,
why the following is giving entire /etc/passwd file as output
even when it does not contain ^ or $ .
grep ' ' /etc/passwd
whereas the following is not giving any output
grep ' ^$ ' /etc/passwd (3 Replies)