[ask]sqlite with shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [ask]sqlite with shell script
# 1  
Old 10-04-2011
[ask]sqlite with shell script

hlow all
i have file like this :
Code:
BDG0100.2011091620162100CF5341.DAT
BDG0100.2011091720175500CF5342.DAT
BDG0100.2011091820192900CF5343.DAT
BDG0100.2011091920210600CF5344.DAT

but now i want make file like this
Code:
20110916.DAT
20110919.DAT
20110918.DAT
20110919.DAT

so what i can do that with using sqlite combine shell script
thx before...

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 10-04-2011 at 12:12 PM..
# 2  
Old 10-04-2011
Quote:
Originally Posted by zvtral
hlow all
i have file like this :
BDG0100.2011091620162100CF5341.DAT
BDG0100.2011091720175500CF5342.DAT
BDG0100.2011091820192900CF5343.DAT
BDG0100.2011091920210600CF5344.DAT

but now i want make file like this
20110916.DAT
20110919.DAT
20110918.DAT
20110919.DAT

so what i can do that with using sqlite combine shell script...
If you are using Bash shell -

Code:
$
$
$ cat f31
BDG0100.2011091620162100CF5341.DAT
BDG0100.2011091720175500CF5342.DAT
BDG0100.2011091820192900CF5343.DAT
BDG0100.2011091920210600CF5344.DAT
$
$
$ while read line; do echo ${line:8:8}${line: -4}; done < f31
20110916.DAT
20110917.DAT
20110918.DAT
20110919.DAT
$
$
$

tyler_durden
# 3  
Old 10-04-2011
I'm not sure sqlite is the appropriate tool here.

some thing like this might do what you need:
Code:
for i in *.DAT; do
   mv $i $(echo $i | sed 's/^[^.]*\.\([0-9]\{8\}\)[A-Z0-9]*\.DAT/\1.DAT/')
done

# 4  
Old 10-04-2011
Code:
cut > _new_ -c 9-16,31- infile && mv --  _new_ infile

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Manipulating UNIX and sqlite db

Hi there, I have multiple rows of data. For example: S/N | Name| Age I would like to store them into sqlite database after doing some grepping in CSV and output them into console/html format. Will it be possible? (1 Reply)
Discussion started by: alvinoo
1 Replies

2. Shell Programming and Scripting

Using sqlite query to build script...

Okay, so this one is a bit above my knowledge level so I'm hoping for some pointers. Here's the scenario: I have a backup system on my network that makes single file images of the machines it's backing up and uses an sqlite database to keep track of everything. As is pretty typical with... (2 Replies)
Discussion started by: NyxPDX
2 Replies

3. UNIX and Linux Applications

ruby/SQLite database interface

Hello, I'm not sure this is quite the right place, but there do seem to be allot of posts with folks using ruby to play nicely with databases so I thought I would give it a go. I am starting a long process of developing a database application bases on SQLite and ruby. This will run on various... (1 Reply)
Discussion started by: LMHmedchem
1 Replies

4. Shell Programming and Scripting

Several processes writing to an SQLite database at the same time

I have several bash scripts that write to an SQLite3 database at the same time. At some occasion the database returns: SQL error: database is locked. How would be the best way, to make a process to wait until the data base is 'free' again. I tried: sqlite3 test.db ".timeout 1000; update....."... (2 Replies)
Discussion started by: creamcheese
2 Replies

5. Shell Programming and Scripting

hell and sqlite

Hi everyone, I have a requirement that requires me to fill an sqlite database with 100,000 entries (no duplicates). I will start out by giving the command that will insert the values necessary to populate the database: # sqlite /var/local/database/dblist "insert into list... (2 Replies)
Discussion started by: ogoy
2 Replies

6. Shell Programming and Scripting

Perl - SQLite question

Hello All, I am trying to write a Perl script that is using 'SQLite' as the application needs a very light weight Database. I wanted to know how to catch exceptions when I run queries in SQLite. Without this the Perl script comes to a halt everytime an exception occurs. Please help. Regards,... (4 Replies)
Discussion started by: garric
4 Replies

7. HP-UX

sqlite database in HP-UX vs Linux

Hi everybody, We have a cgi application which accesses sqlite database. It works fine in Linux environment but the same code doesn't enter data into the database when done in HP-UX environment. Should the codes vary depending on whether it is Linux or HP-UX. Regards Ruma (1 Reply)
Discussion started by: perlprg
1 Replies

8. UNIX for Dummies Questions & Answers

sqlite issue?

i'm on freebsd 5.2.1, and from a fresh installation i've used pkg_add for the latest ported version of apache, as well as installing php 5. supposedly php5 comes with native support for sqlite (in the binary package), and this is what i added. i am trying to install a site engine (the 'gyrator'... (0 Replies)
Discussion started by: brandan
0 Replies
Login or Register to Ask a Question