Search Results

Search: Posts Made By: gugs
5,715
Posted By gugs
otheus there was no reason why I could not use: ...
otheus there was no reason why I could not use:

ls -1t $dir >temp.txt
sed -n "/$NEXT/{p;q}" temp.txt

I don't even know why I didn't think of it! One of those days.

THANK YOU EVERYONE WHO...
5,715
Posted By gugs
Why does this not work?
I have taken the above example and developed a small test script as shown below to do what I want:

NEXT=TEST01
dir='C:/cygwin/var/log/img/aut/'
cmd1="sed -n '/"
echo $cmd1...
5,715
Posted By gugs
How can I identify the last saved log?
Our system produce logs when a script is run which may not be daily, the logs have a format: name_YYMMDD.log - both name and .log are consistent, date changes as per the day the script is run.
...
2,458
Posted By gugs
I was incorrect
ls -1 C:/cygwin/var/log/img/aut/ | grep TEST01_*\.mqsc produced no output.

Anyway, instead of file="TEST01_*.mqsc", file="TEST01" should suffice as I am only interested in files that start with...
2,458
Posted By gugs
I still get the same result
I executed the following:

file="TEST01_*\.mqsc"
ls -1 $dir | grep $file > test.txt
rc=$?
echo "Return Code is: $rc"

The result was:

$ bash -x test.sh
+ delete_files='TEST01_*.mqsc'
+...
2,458
Posted By gugs
Listing a directory via a script using variables
In my script I need to list the directory, where the generic name of the files will change, in my test case its set to TEST_*.mqsc. I wrote a small test script as below, but it just does not pip the...
10,036
Posted By gugs
CMP two files with slight difference and return code
I am comparing two files which are identical except for the timestamp which is incorporated within the otherwise same 372 bytes. I am using the command:

cmp -s $Todays_file $Yesterdays_file -i...
1,799
Posted By gugs
Thanks everyone, really appreciate your help
Thanks everyone, really appreciate your help
1,799
Posted By gugs
Previous log and diff
Logs are created on a daily basis, the format of the log file is: servername_yymmdd. I need to check if there is a difference in the log created today with the previous one. I would appreciate help...
3,818
Posted By gugs
What I ment was a variable....
I was thinking of passing sed a variable, for example:

while read line
do
record=$(printf "%n" "$line" | cut -c1-6000| sed -e 's/[^a-zA-Z0-9+_:-]//g' )
puttime=$(sed<$record...
3,818
Posted By gugs
Is there a way to make this more efficient
I have the following code.

printf "Test Message Report" > report.txt
while read line
do
msgid=$(printf "%n" "$line" | cut -c1-6000| sed -e 's/[^a-zA-Z0-9+_:-]//g' -e...
11,126
Posted By gugs
Era how?
Era, How could I use awk or sed directly on the input file?

Any examples would be welcome
11,126
Posted By gugs
The echo command does not work, can use printf because
When I enter the *echo $line* | cut ...... I get a messages displayed saying *echo: command not found.

Any ideas?



I cant use print command because it doesn't like some characters...
11,126
Posted By gugs
Passing a variable to sed or cut
:confused: Is it possible to send a variable to a sed or cut command? I have a test script as below:

counter=1
while read line
do
# Test the file
printf "$line" > temp$counter
pref=$(cut...
2,578
Posted By gugs
Sample data
cfajohnson, unfortunately I cannot post a copy of the data because I am not allowed, confidential info. The only reason I know that these chars are causing a problem is because I get an on line...
2,578
Posted By gugs
Its not the first character
I am afraid its not the first character, I have specified the message that is displayed on the screen when I run my script which is of the format ./records.sh invalid chracters....etc
2,578
Posted By gugs
How can I get rid of the ` character from input file?
A sed command works most of the time however it fails sometimes.

I put each line (record) I read of a file through the following command
data=$(cat file | sed 's/[^a-zA-Z0-9+_:-]//g' | sed...
984
Posted By gugs
Thank you Annihilannic
I did a cat -vet, it did not show anything peculair. However, I solved the problem by cutting the portion of the data I was interested in and passing it to the sed command.
984
Posted By gugs
Cant get the data I want
Basically I have data that seems to have spaces or some other char that I can not see, please read below:

1/ When I run the command: "cat file | sed 's/[^a-zA-Z0-9+_:-@]//g' | sed...
8,240
Posted By gugs
Thanks for that it works. However what is the best way for?
The sed command has helped in extracting the data I want, however, I lose some of formating i.e. spaces in words. It appears that is what is causing the problem. If I convert the data using sed...
8,240
Posted By gugs
Grep not working - special characters??
I have a file that I am processing with a while loop from, in come cases the grep/sed command (strings record | grep “errorDetail” | sed 's&*errorDetail\(.*)\(/errorDetail\).*&\1&') works and...
1,581
Posted By gugs
Extarcting data from a file that matches two different patterns
Say I have data like shown below. I want all the data that contains XXXX and where it finds XXXX then I also want the Timestamp and the Error fields. I have tried egrep "XXXX|Timestamp" > test.txt....
3,823
Posted By gugs
Detemine if SED is successful
Is there a way of finding out if an issued sed command is successful?

Basically, in my script I have a command where mydata=$(cat record | sed '...command here...'). When the sed command finds...
28,790
Posted By gugs
How can you grep for three fields
I have data, from which I want to grep for two fields. Only pull out the data if both the fields exist.

I have used: egrep --text "field1|field2" file > temp. This seems to be doing an OR. What...
8,204
Posted By gugs
Checking if a file exists
How can I check if a file exists in shell script. Basically, I want to check if a file Test_msgs has been created today. If it has been then append data to it. Otherwise, create it. I have written...
Showing results 1 to 25 of 44

 
All times are GMT -4. The time now is 08:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy