General :: Preserving Last Read Value In Shell Script?
Feb 16, 2011Here are the contents of the file
1600
1900
2200
2800
I want to read file content using shell script and check if the difference between the two line count is 300
Here are the contents of the file
1600
1900
2200
2800
I want to read file content using shell script and check if the difference between the two line count is 300
I am using following code to read a lien from a file and store the value to a variable $line and execute it.
while read line
do
./$line &
[code]...
I am new to writing shell scripts. So, please bare with me. I am currently trying to write a shell script which will read the directory path as input from user and will traverse the Dir tree to find all available audio and video files. I have tried to write as much as I could but I don't know where I am making mistake as I get some files to be audio file which are actully tar balls. On the second note there are some files which video but script shows them to be audio. And, some video files are completely skipped. I am giving the shell script below so that you can see. I am using two external files as source which I am attaching.
Code:
#!/bin/bash
#Let's load the extensions that we want to search for
vdExt=$(cat vdExtList)
adExt=$(cat adExtList)
[code]....
I could understand the idea of security "if I haven't touched the file in 9 days, and the timestamp was changed, I know someone was in my system". But, is there any other purpose for preserving timestamps?
View 3 Replies View RelatedHow can I read .gz file direct on shell/terminal without decompressing the file?
satimis
cp (GNU coreutils 6.9).
I have these files:
Code:
I want to copy them to /xp/borrar/ such that the result is
Code:
Can this be done with the cp command alone?
I need to copy my data from the pc to an external hard drive with keeping the attributes; so i used the command
cp -rp ~/sourceDir ~/Destination
but when i am coping it it give the error message "cp: failde to preserve ownership for 'file' : Operation not permitted and it copied the files to the destination but the attributes has changed from
-rw-r--r-- to
-rwxr-xr-x
I tried to copy it by loging as the root also but still the same thing happens. how to copy the files with preserving the attributes
How to backup my Linux server for preserving data in case if hard disk crashes?
View 2 Replies View RelatedIf I have a partition like /dev/hd1 that is unencrypted and want it to be encrypted, but want to keep everything currently in that partition, how can I do that?
View 2 Replies View RelatedI'm searching for a tutorial on how to convert my videos (AVI, WMV and MKV formats) to a format that offers both good quality and small size.The audio part should be 128 kbit/s mp3 lame.I'm using Fedora 14 with an rpmfusion repo. It would be especially nice to be able to batch-convert the AVIs.
View 1 Replies View RelatedI would like to find the command that copy my eclipse options to another workspace code...
It doesn't work, and it could be source of error to write the path .metadata/.plugins manually. It certainly a better idea to create a complete script ?
I would like to remove almost all of the Privacy Evading data that a digital camera is generating, such as EXIF DATA. EXIF DATA: Camera Brand, Camera Model, Date taken, Exposure Time, Flash Fired, Focal Length, Location (if you are using iPhone with categorization by location, if enabled), Metering Mode, etc.
May you, please, write a script which does that job for multiple files?Exiv2 seem to reduce more weight than Jhead so I'll use the command exiv2.That's, generally, what I want the script to do:Retrieve the (Modified) date of a file.
So I have a bunch of directories:
dir1
dir2
dir3
etc.
which themselves all contain subdirectories:
dir1subdir1subdir2etc.and at the lowest level they contain all of these jpegs that I need. The problem is that I only need some of them. They're named like this:
pic1.jpg
pic1_med.jpg
pic1_small.jpg
pic2.jpg
pic2_med.jpg
etc.
I want to just grab the ones without the size suffix and copy them all to another set of folders, while preserving the directory structure. The numbering all starts at 1 for each low level subdirectory, so I think that the directory structure is the only way to not get them mixed up.
I know that cp has a recursive option -r but how do I just extract the ones without the underscore? And then how do I preserve the directory structure when I move them over?
So my firefox's profile.ini file looks like this:less .mozilla/firefox/profiles.ini
Code:
[General]
StartWithLastProfile=1
[code]...
I'm trying to write a small application controlling spotify, running under wine, that I can run from my desktop computer and use via SSH on my mobile phone, and so far I've been quite successful. At least until just recently, when I tried to use the read command to read a single key-press on my phone, and use that input instead of having to type the number for item in the menu I've created. I tried to simply use the read command to silently listen to one key-press and output it to the variable opt. To do this I tried:
read -s -n1 opt
When I ran this in a shell-script this I got:
read: 1: Illegal option -s
Seeing this, I tried to remove the -s operator, which left me with:
read: 1: Illegal option -n
I decided to remove all operators and echo the variable opt, leaving me with:
read opt
echo "$opt"
Which worked as expected. It echoed the key that I had pressed. I moved over to my terminal window and tried the read command from there, and it did exactly what it should. It silently recorded one key-press to the variable opt.
why isn't read working with operators in shell scripts?
I have a text file that looks sort of like this:
Code:
blah blah blah
tons of unimportant stuff we don't care about
[code]...
I have 2 external hdd in wich I have all my files. yesterday, I have copied all the files from hdd2 to hdd1 and I want to eliminate duplicates so I used FSLint to find them,now I want to make a shell script to delete all the files/entries (read from the log file) that begin with.
View 14 Replies View RelatedTrying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.
The script is the following but i get an error saying "[: 6: =: argument expected"
I have 2 external hdd in wich I have all my files.... yesterday, I have copied all the files from hdd2 to hdd1 and I want to eliminate duplicates so I used FSLint to find them, now, I have a txt file that looks like this:
Code: /media/My Book/!!!MIS DOCUMENTOS/Documentos/2 sep2003-jun2009 USB/!TESIS/TESIS/TESIS CVT LABVIEW Y CODEWARRIOR/LabVIEW85RuntimeEngineFull.exe /media/My Book/HDD_Toshiba/Borrable/Pen_Drive_4GB/Tesis/Super CD de la tesis/LabView/LabVIEW85RuntimeEngineFull.exe multiplied by millions of entries...
now I want to make a shell script to delete all the files/entries (read from the log file) that begin with:
Code:
/media/My Book/HDD_Toshiba/**** Since HDD_Toshiba is the folder in hdd1 (MyBook) that contains all the files from hdd2
I want my samba to keep my windows attributes exactly what the user setted in windows I mean if it has read only file in win box and copy it to samba share ,samba keep it read only and same for other attributes but it does not do it now with my configuration:Quote:
[global]
workgroup = DOMAIN
server string = File Server
[code]...
MACHINE: HP Proliant DL260G5OS: SLES 11 SP1kernel: Linux xserver 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/LinuxIt is used as remote xserver in a LAN.I have configured /usr/lib/restricted/bin/.rbashrc with some environment variables but when the users logon in the system finally is executed $HOME/.bashrc and some environment vars are overwritten.
View 2 Replies View RelatedI would like know when it is necessary or advisable to write a shell script instead of shell function ?
View 3 Replies View RelatedCode:
cat ${SOURCE}/{start,universal,index,end}.txt > ${SERVER}/index.html
cat ${SOURCE}/{start,universal,02042010,end}.txt > ${SERVER}/02042010.html
[code]....
Well, I am facing one issue:How can i read two files word by word at a time using any loop as i need word by word comparision in shell script?Please let me know pseudo code.
View 14 Replies View RelatedI have a output file look like this:
{"test1" : "test2", "test3" : "test4"},
How can I read word by word in each line?This is not working code:
a=0
while read word
do a=$(($a+1));
[code]...
I am wondering if I can open a shell or new terminal thing from within the terminal in a unix/linux enviroment. Particularly a commandline only one where there is no GUI. Is this doable? how do I do it?
View 3 Replies View Relatedcurrently my installation is on sda1, while /home is on sdb1. I'd like to wipe sda1 and reinstall Ubuntu 10.04 from scratch.
Can I just run the 10.04 installer, reformat sda1, install 10.04 over it, then follow a guide to remount sdb1 to /home (and chown the new /home)?
Using "List View" in Nautilus (Ubuntu 9.10), is there a way to preserve the column width? If I manually change the column width and click into another folder, the width automatically reverts to the old width when I return.
View 4 Replies View RelatedI disliked LXDE's pcmanfm so much that I've switched over to feh and idesk but for the life of me I can't get feh's wallpaper setting to stay between sessions. Typing 'feh --bg-scale /usr/share/lxde/wallpapers/lxde_blue.jpg' immediately gives me what I want, but next login it's gone again. I know I have to put an entry in ~/home/pargoo/.config/openbox/autostart.sh but nothing works. So far I've tried:
eval `cat $HOME/.fehbg` &
eval `cat $HOME/pargoo/.fehbg` &
eval `cat ~/.fehbg` &
[Code].....
What are the possible problem when Windows access the file from Ubuntu got Read Only even though have a full permission to read, write and execute the file? Ubuntu to Ubuntu accessing the file there is no problem only Windows got a problem.
View 1 Replies View Related