How to remove // inbetween the files contents?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to remove // inbetween the files contents?
# 1  
Old 11-28-2012
How to remove // inbetween the files contents?

Hi Am Using unix Aix

Have a file name called FILE1
having the content of FILE1 is
Code:
cat FILE1
 
01/11/2012
03/11/2012
//
//
//
04/11/2012

I Need Output as:-
Code:
cat FILE1
01/11/2012
03/11/2012
04/11/2012

Wants to remove the backslash(//) can anyone help me pls ?
# 2  
Old 11-29-2012
Code:
awk '$0 != "//"' FILE1

# 3  
Old 11-29-2012
Code:
 
sed -e 's|//||g'   -e '/^$/d' FILE1

# 4  
Old 11-29-2012
Code:
grep [0-9] FILE1
grep -v // FILE1

# 5  
Old 11-30-2012
some lazy one :

Code:
awk '/.../' FILE1

Code:
grep ... FILE1

---------- Post updated at 12:48 AM ---------- Previous update was at 12:45 AM ----------

Code:
$ cat tst

01/11/2012
03/11/2012
//
//
//
04/11/2012
$ grep ... tst
01/11/2012
03/11/2012
04/11/2012
$ awk '/.../' tst
01/11/2012
03/11/2012
04/11/2012
$

This User Gave Thanks to ctsgnb For This Post:
# 6  
Old 12-02-2012
Quote:
Originally Posted by Scott
Code:
grep [0-9] FILE1

That's a command which will be at the mercy of the contents of the current/working directory, for getting the intended results.

If the working directory has files/directories named with a single digit, then the shell will expand the glob [0-9] to the name/s of those files/directories and the grep will search with the wrong expression/string and/or in wrong files (if multiple filenames match the glob).
# 7  
Old 12-02-2012
Some more Smilie
Code:
grep -v ^/ file

Code:
grep '[^/]' file

Code:
awk -F/ \$1 file

Some awks:
Code:
awk NF-2 FS= file

Code:
sed \\-//-d file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove contents from file which are under bracket?

hello Friend, In hostgroup file, i have define lots of hostgroups. I need to remove few of them without manually editing file. Need script or syntax. I want to search particular on hostgroup_members and delete hostgoup defination of it. for example. define hostgroup{ hostgroup_name... (8 Replies)
Discussion started by: ghpradeep
8 Replies

2. Shell Programming and Scripting

Remove or rename based on contents of file

I am trying to use the two files shown below to either remove or rename contents in one of those files. If in file1.txt $5 matches $5 of file2.txt and the value in $1 of file1.txt is not "No Match" then that value is substituted for all values in $5 and $1 of file2.txt. If however in $1 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

Remove folder contents

for dir in BKP/*/ do echo You are in :$dir done O/P -- BKP/201448/ BKP/201449/ BKP/201450/ BKP/201451/ BKP/201452/ BKP/201501/ BKP/201502/ BKP/201503/ BKP/201504/ BKP/201505/ BKP/201506/ BKP/201507/ (3 Replies)
Discussion started by: rocking77
3 Replies

4. Shell Programming and Scripting

How to remove a line based on contents of the first column?

Good day all. Using basic UNIX/Linux tools, how would you delete a line based on a character found in column 1? For example, if the CITY name contains an 'a' or 'A', delete the line: New York City; New York Los Angeles; California Chicago; Illinois Houston; Texas Philadelphia;... (3 Replies)
Discussion started by: BRH
3 Replies

5. Shell Programming and Scripting

How to Remove the new line character inbetween a record

I have a file, in which a single record spans across multiple lines, File 1 ==== 14|\n leave request \n accepted|Yes| 15|\n leave request not \n acccepted|No| I wanted to remove the '\n charecters. I used the below code (foudn somewhere in this forum) perl -e 'while (<>) { if... (1 Reply)
Discussion started by: machomaddy
1 Replies

6. Shell Programming and Scripting

Remove lines based on contents of another file

So, this issue is driving me nuts! I was hoping to get a lending hand here... I have 2 files: file1.txt contains: this is example1 this is example2 this is example3 this is example4 this is example5 file2.txt contains: example3 example5 Basically, I need a script or command to... (4 Replies)
Discussion started by: bashshadow1979
4 Replies

7. Shell Programming and Scripting

Compare two files and remove all the contents of one file from another

Hi, I have two files, in which the second file has exactly the same contents of the first file with some additional records. Now, if I want to remove those matching lines from file2 and print only the extra contents which the first file does not have, I could use the below unsophisticated... (3 Replies)
Discussion started by: royalibrahim
3 Replies

8. Shell Programming and Scripting

Query:just need to remove the contents of the file without deleting that

Hii, Please suggest me how can i only remove the contents of the file without deleting it. (3 Replies)
Discussion started by: namishtiwari
3 Replies

9. Solaris

remove the contents of a file

Hi Let say a flat file contains 1000 lines. The cursor is at the 530 line number. Now I like to delete all the line at one ahot. how it can be done? (2 Replies)
Discussion started by: surjyap
2 Replies
Login or Register to Ask a Question