General :: Sed Command - Find Line Not Beginning With Double Quote
Mar 15, 2011
I need to find each line in a file which does NOT begin with a double quote (") and append that line to the previous line. I have been successful doing this using the following command:
cat filname.csv | sed -e :a -e '$!Ns/
[^"]//;ta -e 'P;D' > newfilename.csv
My issue is the substitution. As you would expect after the line is appended to the previous line the first character is removed. I need it to not be removed. I tried:
cat filname.csv | sed -e :a -e '$!Ns/
[^"]/&/;ta -e 'P;D' > newfilename.csv
but it just hangs.
Goal:
Input:
"line 1"
line 2
Output with existing sed command is:
line 1ine2
I need it to be line1line2.
View 9 Replies
ADVERTISEMENT
Aug 12, 2010
I want to watch a number of processes in "D" status repeatedly with following command:Code:# watch -n 1 'top -b -n 1 | awk '{if ($8 == "D") {print; count++} } END {print count}''but it didn't work. I also tried with double quote. Can I use 'watch' command is this case?PS: I know 'while' and 'sleep' can do the same but it is dirty workaround.
View 2 Replies
View Related
Jan 21, 2010
I want to convert double quote to single quote in a text file. I tried escape characters however no success. Please find details as follows:
-sh-3.00$ sed 's/"/'/g test.txt
sed: -e expression #1, char 7: unterminated `s' command
-sh-3.00$ cat test.txt
"unix"
I want "unix" to be converted to 'unix'
View 7 Replies
View Related
Oct 27, 2010
I need sed to be able to search a string that includes both single quotes (') and double quotes ("). can anyone help me out, there has to be a way to do this.
So far I have tried:
But none of these work and I cannot think of how else to escape the sed quote inside of brackets.
View 3 Replies
View Related
Jul 15, 2011
Is there a way to specify to find that I only want text files (and not binary files)? Grep has an option to exclude binary files, so I thought find probably has a similar feature, but I've been unable to find it.
View 2 Replies
View Related
Feb 28, 2011
I have a lot a folders, each named by a number, and in each of these folders I have a specific file (stddev.dat) containing a single line (of numbers) I need to have a single file with each line being one of the stddev.dat (no matter if it is sorted or not), and also I need to add at the begining of each line the number of the folder it comes from.
I 'm no bash expert, and the "add at the begining of the line" is a bit of problem to me". Here is what I've come up with so far, just to put everything in one file, (and also if you know a better/more elegant way to do the same thing I've done, I'm listening)
[Code]...
View 6 Replies
View Related
Aug 5, 2010
I am trying to create a shell script where a user can specify a file with a list of logins and the script will create a batch file with specific information in specific columns.
Example:
loginfile.txt has
User1
User2
User3
I need the output to be as below:
1 User1 Date 12/31/9999
2 User2 Date 12/31/9999
3 User3 Date 12/31/9999
Where the columns are separated as below.
1[tab][tab]User1[tab]date +%D[tab]12/31/9999
2[tab][tab]User2[tab]date +%D[tab]12/31/9999
3[tab][tab]User3[tab]date +%D[tab]12/31/9999
I can use the nl utility to get the numbers easily enough, but I need two tab separations between the number and the user list. Is there a sed command that will insert at the beginning of each line? If so I can just run nl after I get some tabs up in the front.
View 2 Replies
View Related
Apr 1, 2009
Was wondering if any perl guru's could help me with a quick log file adjustment. I have a text file that looks like so (tabs and newlines are revealed so you can see what separates the data):
There are maybe 100 lines of text in this file at any given time. I need to delete all duplicate lines only looking at the first bit of text prior to the first tab. It doesn't matter which one gets deleted as long as there are no two lines that begin with that same text at the beginning before the first tab. So in this example, either the fist line "1234" or the last line "1234" would need to be deleted. I already have code in my script that opens the files - I just need the code to read the text into an array and the part that would find matches based on the above criteria, and make the deletions.
If it would be easier, I can even do a system call and use SED (v4.1.5) and/or AWK (3.1.5) instead.
View 7 Replies
View Related
Feb 24, 2010
How can i find through terminal that which devices are external and which are internal.
By external i mean devices attached to USB port. For Example, USB Drive, Portable USB HardDrive etc.
By internal i mean devices attached internally. For Example, SATA Harddisk etc.
View 2 Replies
View Related
Jul 12, 2010
I read this thread but
Code:
anisha@linux-uitj:~> su
Password:
[code]...
View 14 Replies
View Related
Jun 24, 2011
I'd like to measure network latency for SNMP GET request. There is a free command line tool time which can be used to find timing statistics for various commands. For example it can be used with snmpget in the following way:$ time snmpget -v 2c -c public 192.168.1.3 .1.3.6.1.2.1.2.2.1.10.2IF-MIB::ifInOctets.2 = Counter32: 112857973real 0m0.162suser 0m0.069ssys 0m0.005sAccording to the manual, statistics conists of:
the elapsed real time between
invocation and termination,
the user CPU time (the sum of the
[code]....
View 3 Replies
View Related
Dec 6, 2010
I want to add something at the end of each line, from line 4 to line 8, in vim? How can i do that? I know adding at the beginning is like: 4,8: normal: i# What i want to add contains special characters ( here it is: <br/> ) , in case that matters.
I want to add tabs at the beginning of each line, from line 6 to line 12. How?
View 1 Replies
View Related
Aug 3, 2010
I need to output of a script to a file with tags.
I'm trying sed and was able to put a tag on the end of the line
Code:
Output is
Quote:
What I need to have is
Quote:
I'm thinking of I redirect my first sed command to a file and then use sed again to put <group> at the beginning of the line. My problem is how to put <group> to all beginning of the string.
View 2 Replies
View Related
Apr 16, 2010
I try to do a function which removes '#' from beginning of line. But if there is not '#' then add it on beginning of line. I try something like this, can you correct me?
Code:
awk '
!/^#/{ sub(/^[^#]*/,"#$0","'$line'")
}
/^#/{ sub(/#/,"","'$line'")
}'
View 14 Replies
View Related
Oct 17, 2010
I am having some difficulties with an expect script. What I want is that as soon as expect sees a newline followed by a dollarsign ($), that interact is done. So I would expect something like this to work:
Code:
"
$" { interact }
However it doesn't.
This is debugging output:
Code:
expect: continuing expect
expect: does " " (spawn_id exp6) match glob pattern "#"? no
[Code]...
View 3 Replies
View Related
Feb 16, 2010
What's that bash command that automatically inserted a quote at the end of your email? Can't recall exactly, is floating round at the back of my mind.
View 4 Replies
View Related
May 25, 2010
How do I find files in opensuse 11.2 without using the command line. I see in dolphin "nepomuksearch", but it doesn't work. Even in the command line you cannot whereis a file like Monday, Monday.mp3. whereis also seems to be case sensitive.
View 5 Replies
View Related
Jun 21, 2010
Does any one know what syntax i could use to allow me to replace all instances at the beginning of a line with ones.
Before :
Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
Logical device name : RAID1Mirror
RAID level : 1
Status of logical device : Optimal
After
Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
111Logical device name : RAID1Mirror
1111RAID level : 1
11111Status of logical device : Optimal
View 12 Replies
View Related
Mar 2, 2010
command line, I have a server for work that I ssh into and I need to be able to find multiple files (they have the leading text just the date identifier changes) and then zip the files (with bzip) them and then finally scp(Secure copy) them to another server.
These files are always in the same directory and this is a daily task and just want to make into a script that I run once I am logged into the remote server.
View 4 Replies
View Related
May 14, 2010
How do you find and use file manipulation tools on the command line?
View 1 Replies
View Related
May 13, 2010
So, in finishing my nFlux slack current edition.I have set it up for users to do certain things in console
and one of the things I want is a way to view slackbook-2.0 in runlevel 3 console.I cant find a pdf reader that works in command line mode and I cant figure out how to either convert slackbook 2.0 pdf into html/text Or find a slackbook download that is html or text?I tried converting it using pdftotext, which didnt work very well So, I need a command line pdf viewer or a converter that works good?
View 5 Replies
View Related
Aug 28, 2010
I'm pretty sure this is doable from the command line, but my CLI skills have degraded a lot since my pre-Y2K admin days. The goal is to search all the files in the directory for a very long string of text and replace it with another string of text. The text being searched for is my Google Adsense code (which will be stripped from my website) and it will be replaced with a placeholder so I can easily tack something else in there in the future.
Seeing how I have that long snip of code on about 100 pages, automating the process would make life easier.
If I was searching for a single word, I can see ways to do this.
If I paste the code I'm searching for into a text file, is there a way to:
find (contents of oldstring.txt) and replace with (contents of newstring.txt)?
View 9 Replies
View Related
Aug 23, 2010
I am able to start up firefox just fine out of my terminal, but i have not been able to find any list of arguments that can be added in the command line. what i'm looking for is that it starts up in Full Screen mode right off. is there an argument that can be added to ti to do that?
View 2 Replies
View Related
Nov 15, 2010
I want to write a small script to rename a bunch of files. Their name is of the form 'long number'|'name'|'extension', for example:
52354Football_part2.flv
2353452Nice_weather_4_ducks.flv
I would like to rename these to:
Football_part2.flv
Nice_weather_4_ducks.flv
If in my script I use something like
Code:
sed s/[0-9]//g
on each file, I will get
Football_part.flv, instead of Football_part2.flv,
and
Nice_weather__ducks.flv, instead of Nice_weather_4_ducks.flv.
how to instruct sed to only remove numbers that are in the beginning of the name in a simple way?
View 2 Replies
View Related
Apr 14, 2010
i'm trying to setup my server box.. it's being setup as a web server, file server, and setup for me to be able to access it remotely (aka i do pc repair for windows users and it'd be nice to just know where ALL of my software tools are and get to them from there)anyways.. these things are almost all setup right now.. but the one thing i'm having issues with.. is the fact that this box does have 2 hard drives in it and i want to use both of them.. now i'm running straight command line and i can't find the info i need to reformat the second HDD (which is currently NTFS formated) and use it in this system... i'm running 9.04 as a server.. NO GUI INSTALLED! i need this with straight command line...What do i need to look for to figure this out? i'm having trouble figuring this out and it's really getting annoying..
View 5 Replies
View Related
Feb 24, 2011
I'd like show a certain line or lines of a file with context, kind of like a unified diff, on the command line in Linux:
$ (something) -l 154 stuff.py
150: def foo(bar):
151: """
[code]....
View 5 Replies
View Related
Aug 22, 2011
How can I print Linux command line history without including the line numbers? I want to send it all to a text file like this:history >> history.txt
View 1 Replies
View Related
Jan 7, 2010
I can't find kmod so I'll go for the Nvidia installer from [URL]. I tried to run it Quote: su -c 'sh NVIDIA-Linux-x86-XYZ.AB.pkg1.run' but it wants me to kill xserver. How can I do that? " gdm stop" will kill Xserver too? How will I start it again?
View 3 Replies
View Related
May 29, 2010
i've gotten my fedora 12 to the point where i can run python3 scripts from command line and can call up python 2.6.2 idle with the command 'idle' from command line. what command will call up python3 (3.1.2 to be exact) idle?
View 5 Replies
View Related
Mar 26, 2011
I know my way around MS Windows much better, but I just don't feel right trying to program something for Android on a Microsoft operating system. I am interested in Android programming so I followed the instructions on [URL] to install the environment on my computer...
I just installed the JDK, SDK, Eclipse successfully (or I assume):
* When I get to Step 4 where I'm supposed to run 'android' it will not run. I get the error message "android: command not found" (I am definitely in the right directory).
** When I double-click it in nautilus, it opens up in gedit. I can set the permissions in nautilus (through the properties - Allow executing file as a program) and get it to work,
My system:
Intel i7
Ubuntu 10.10 Maverick Meerkat
android-sdk-linux-x86
eclipse 3.6.2
View 5 Replies
View Related